How we configurate cable.yml (Action Cable) using postgresql? - ruby-on-rails-6

I try to configure the cable.yml like this
development:
adapter: postgresql
test:
adapter: postgresql
production:
adapter: postgresql
url: ?
channel_prefix: ?

it's better if you can use a cache service like redis https://redis.io/ for better performance as you'll be roughly hitting the db with the notification system for each user with an always-open socket.
But you can configure your yml file as follow:
development:
adapter: postgresql
test:
adapter: postgresql
staging:
adapter: postgresql
production:
adapter: postgresql
url: production_db_url
channel_prefix:
see the documentation at this specific part where it mentions redis in production at least for the same reason I mentioned before :
https://edgeguides.rubyonrails.org/action_cable_overview.html#subscription-adapter

Related

AKS Network Policy: Why the "host" could not be resolved when adding network policy?

I have kubernetes Cluster deployed on Azure (AKS). On that cluster i have a wordpress deployed with helm. And Azure mariadDB which is accessible to Worpress via External Service Object:
My External service look like :
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: app
spec:
type: ExternalName
externalName: somename.mariadb.database.azure.com
I defined network policy on my Wordpress chart. And the values.yml look like:
# Azure MariaDB infos
externalDatabase:
#host: 10.0.4.68 # IT WORKS FINE WHEN I PUT MARIADB IP
host: mysql # IT DOES NOT WORK WHEN I PUT EXTERNAL SERVICE OBJECT NAME NOR THE FOLLOWING ENFPOINT: somename.mariadb.database.azure.com
port: 3306
database: bitnami_wordpress
networkPolicy:
enabled: true
ingressRules:
accessOnlyFrom:
enabled: true
customRules:
- {}
egressRules:
customRules:
- to:
- ipBlock:
cidr: 10.0.4.64/28 # THE VSUBNET OF MARIADB DATABASE
ports:
- protocol: TCP
port: 3306
When i replace externalDatabase.host with the IP of MariaDB it works fine. But when replace it with the external service object name (ie: mysql which is the 1st manifest) or with the endpoint (ie: somename.mariadb.database.azure.com ) i got the follwing error:
wordpress 15:35:09.41 DEBUG ==> Executing SQL command:
SELECT 1
ERROR 2005 (HY000): Unknown server host 'somename.mariadb.database.azure.com' (-3)
wordpress 15:35:34.43 DEBUG ==> Executing SQL command:
PS: the above error is when i set externalDatabase.host to somename-dev.mariadb.database.azure.com which is the same error as when externalDatabase.hostset to mysql
Any help please

Manage Symfony App Heroku

I've a Symfony app on Heroku with ClearDb addons. I need to manage the app for test and prod. So I need two database: one for test and one for the production(principle);
I tryed the Heroku Pipeline, but when I promote the app from staging to production, the production app is connetted to staging db. How can solve ?
How you manage it?
EDIT
I discovered the mistake. I set the parameters via
$db = parse_url(getenv('CLEARDB_DATABASE_URL'));
$container->setParameter('database_host', $db['host']);
From a quick search for $container->setParameter I can see that this is a Symfony feature to interpolate values into code, however they mention the following warning in their docs:
NOTE: You can only set a parameter before the container is compiled:
not at run-time. To learn more about compiling the container see
Compiling the Container.
https://symfony.com/doc/current/service_container/parameters.html#getting-and-setting-container-parameters-in-php
Heroku handle only symfony apps in prod env. So the stage app also have the environment var as "prod". How can I set parameters for different env? Or dynamically?
Thanks,
AlterB
I've solved with the Environment Variables.
I changed into app/config/config.yml this:
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
with that
doctrine:
dbal:
driver: pdo_mysql
url: '%env(CLEARDB_DATABASE_URL)%'
The app gets the db connection directly from Heroku Env. And it's done!

salt-cloud minion install/config on windows VM

I'm trying to test salt-cloud with vmWare/vCenter and all is really good so far. However it appears the minion is not being installed on the VM. I have been digging around and the only settings I find are
http://salt-cloud.readthedocs.io/en/latest/topics/windows.html
my-softlayer:
provider: softlayer
user: MYUSER1138
apikey: 'e3b68aa711e6deadc62d5b76355674beef7cc3116062ddbacafe5f7e465bfdc9'
minion:
master: saltmaster.example.com
**win_installer: /root/Salt-Minion-0.17.0-AMD64-Setup.exe
win_username: Administrator
win_password: letmein**
Does this mean, I need to have the windows installer in /root for salt-cloud to run? I thought setting deploy: True would do the install. Below is my config. my vlan is using dhcp, so I am getting a good IP and all.
cloud.profile.d/test.conf
windows-test:
provider: vcenter
clonefrom: 'Win2K12'
num_cpus: 1
memory: 2GB
devices:
network:
Network adapter 1:
name: vlan
adapter_type: vmxnet3
switch_type: distributed
cluster: cluster
datastore: datastore
folder: 'OS Testing'
power_on: True
deploy: True
customization: False
win_username: Administrator
win_password: password
minion:
master: salt
EDIT
I do have to specify the installer location. That seems to work. The problem now is trying to get pywinrm/Windows Remote Management to work. For some reason salt-cloud is trying to connect on 5986, but looking at the VM I see WRM is listening on 5985. So I'm wondering if it's a pywinrm setting now???

How to setup Sylius to use Redis as Cache Backend

According the https://github.com/doctrine/DoctrineCacheBundle#cache-providers there are several parameters necessary to use redis instead of file_system as cache backend.
In the main configuration file of Sylius, there is only one area to put cache settings:
app/config/parameters.yml
sylius.cache:
type: redis (was file_system)
Where to put the rest?
connection_id - Redis connection service id
host - redis host
port - redis port
Thanks!
You can use this syntax:
sylius.cache:
type: redis
namespace: sylius
redis:
host: localhost
port: 6379
database: 10
Sylius then creates a doctrine cache provider with this configuration.

Logging messages to Redis with monolog is not working

I want to log messages to a local Redis server with Monolog in a Symfony 2 project. I'm using the SncRedisBundle for this purpose.
This should be straight forward following the documentation, but it seems that no messages are stored in Redis. If I use the the default Redis client configured and write something to the Redis server this works perfectly.
My configuration is the following:
snc_redis:
clients:
default:
type: predis
alias: default
dsn: redis://localhost
monolog:
type: predis
alias: monolog
dsn: redis://localhost/1
logging: false
options:
connection_persistent: true
monolog:
client: monolog
key: monolog
monolog:
handlers:
custom:
type: service
id: snc_redis.monolog.handler
level: debug
Does anybody know how I can fix this issue?
You have to watch out for the fact that monolog handlers are redefined in config_prod.yml and config_dev.yml, so if you define them in config.yml they will just be overwritten by the prod or dev config. I'm not sure where you did it but if you have the redis and monolog configs together it is a probable cause that you just configured monolog in the wrong file.

Resources