Does anyone know the best way I can create a configuration for a Console/Command-line Command (or indeed in any part of the application?)
What I would like to achieve is this (for example)
$ app/console myapp:sync --server=server_2
connecting to "server2.servers.com"...success!
sync completed.
Where myapp is a command line class under /src/myBundle/Command/SyncCommand.php
and in the configuration (app/config/config.yml?) this:
myapp:
server_1:
hostname: "server1.servers.com"
port: 22
server_2:
hostname: "server2.servers.com"
port: 22
For this example it isn't important what the sync does (the code has already been written as SyncCommand.php), I am just interested in knowing in which configuration file to use (I presume either config.yml or parameters.ini) and how to read that config out (treeBuilder? or something like $this->getParameters('myapp')? I suspect I am missing something obvious somewhere.
Thanks!
In the command you have access to the container with getContainer() method if you extend the ContainerAwareCommand class.
You can define your configurations in the parameters section of the services file:
parameters:
server_1:
hostname: "server1.servers.com"
port: 22
server_2:
hostname: "server2.servers.com"
port: 22
Then you should be able to access them with the container (just like described in another question):
$this->getContainer()->getParameter('server_1');
Related
I'm getting error when configuration file is set.
My host is a Ubuntu 22.04
Inside the docker container the user is rabbitmq, using id -u rabbitmq the $UID is 999
I changed the file using: chown 999 advanced.config
But the same error still persists.
Failed to load advanced configuration file "/etc/rabbitmq/advanced.config": unknown POSIX error
Error during startup: {error,failed_to_read_advanced_configuration_file}
version: "3.2"
services:
rabbitmq2:
image: rabbitmq:3-management
hostname: rabbitmq2
container_name: 'rabbitmq2'
ports:
- "5672:5672"
- "15672:15672"
- "5552:5552"
volumes:
- ./advanced/rabbitmq2/advanced.config:/etc/rabbitmq/advanced.config
# or using:
# - type: bind
# source: $PWD/advanced/rabbitmq2/advanced.config
# target: /etc/rabbitmq/advanced.config
environment:
- RABBITMQ_ADVANCED_CONFIG_FILE=/etc/rabbitmq/advanced.config
If I use another place to put the file, or another file name, the container runs, but Rabbitmq doesn't load the configuration file.
I changed the content of the file and it didn't work (rabbitmq can't load the file), I tried using blank file, and using some configurations, for example:
[
%% 4 replicas by default, only makes sense for nine node clusters
{rabbit, [{quorum_cluster_size, 4},
{quorum_commands_soft_limit, 512}]}
]
Be sure the format is correct:
[
%% 4 replicas by default, only makes sense for nine node clusters
{rabbit, [{quorum_cluster_size, 4},
{quorum_commands_soft_limit, 512}]}
].
Note the trailing period.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
I want to proxy mongodb behind nginx. And I came across following code for same purpose.
My question is, how can I enable "stream" module in nginx?
stream {
server {
listen 27020;
proxy_connect_timeout 5s;
proxy_timeout 20s;
proxy_pass mongodb_host;
}
upstream mongodb_host{
server xx.xxx.xxx.xx:27017;
}
}
Technically recompiling using the --with-stream option is required, as per the nginx docs. Fortunately there are plenty of existing images for that purpose. I've used this one personally: https://hub.docker.com/r/tekn0ir/nginx-stream
If using compose, your docker-compose.yml file would look something like this -
version: '3'
services:
service1:
...
service2:
...
nginx:
image: tekn0ir/nginx-stream:latest
ports:
- "27020:27020"
volumes:
- /usr/local/nginx/conf/http:/opt/nginx/http.conf.d
- /usr/local/nginx/conf/stream:/opt/nginx/stream.conf.d
Create 1 or more files in the "/usr/local/nginx/conf/stream" directory containing your code stream { ... } . Config file names just need to end with the ".conf" extension. Then you can create any http config files in "/usr/local/nginx/conf/http".
Straight from the nginx documentation:
"The ngx_stream_core_module module is available since version 1.9.0. This module is not built by default, it should be enabled with the --with-stream configuration parameter."
We changed the configuration of our WebLogic servers to use HTTPS and T3S for connections and use the secure encrypted port 9002 instead of cleartext port 7001. However when using the Web Logic Scripting Tool (WLST)'s connect() function, errors are thrown. One such error is as follows:
WLSTException: Error occurred while performing connect : Cannot connect via t3s or https. If using demo certs, verify that the -Dweblogic.security.TrustKeyStore=DemoTrust system property is set. : t3s://DatServer:9002: Destination 10.10.100.3, 9002 unreachable; nested exception is:
javax.net.ssl.SSLHandshakeException: General SSLEngine problem; No available router to destination
Use dumpStack() to view the full stacktrace :
The syntax of the connect function is: connect('user', 'password', 't3s://host:9002')
This connect() function works fine before the switch from HTTP to HTTPS. Now we cannot connect to the remote admin server using the connect command. Does anyone have any idea how to fix this?
I read some interesting help options but none of them seemed to work. These help suggestions and tips are located here: https://community.oracle.com/thread/1036828
We were able to connect to the remote host and port via telnet. We saw that the port is open and listening for connections on the loop back address with netstat. We tried adding these options to the script invocation: java -cp /path/to/weblogic.jar weblogic.WLST -Dweblogic.security.TrustKeyStore=DemoTrust -Dssl.debug=true Dweblogic.security.SSL.ignoreHostnameVerification=true -Djava.security.egd=file:/dev/./urandom but this also did not work.
We enabled tunneling in the General tab of WebLogic but not in the HTTP tab. I am not the one in control of the server so I just have to suggest things and hope that the instructions are followed.
I get it running in 12.2. by adding to
../oracle_common/common/bin/setWlstEnv_internal.sh
at the end the following lines (youu need to customize line 5 und 6, the values in brackets):
JAVA_OPTIONS="-Dweblogic.ssl.JSSEEnabled=true ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.SSL.enableJSSE="true" ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.SSL.ignoreHostnameVerification=true ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.TrustKeyStore=CustomTrust ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.CustomTrustKeyStoreFileName= ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.CustomTrustKeyStorePassPhrase= ${JAVA_OPTIONS}"
JAVA_OPTIONS="-Dweblogic.security.CustomTrustKeyStoreType=JKS ${JAVA_OPTIONS}"
export JAVA_OPTIONS
and modifying in
../oracle_common/common/bin/wlst_internal.sh
the line starting with
eval '"${JAVA_HOME}/bin/java"' ${JVM_ARGS} ...
by adding ${JAVA_OPTIONS}
so that it looks as follows:
eval '"${JAVA_HOME}/bin/java"' ${JVM_ARGS} ${JAVA_OPTIONS} weblogic.WLST '"$#"'
Hope this helps, allthough modifying scripts that are named "..internal.." doesn´t give me a good feeling
export this before running wlst.sh
export WLST_PROPERTIES=" -Dweblogic.security.TrustKeyStore=CustomTrust -Dweblogic.security.CustomTrustKeyStoreFileName=/u01/oracle/properties/truststore.jks -Dweblogic.security.CustomTrustKeyStoreType=jks -Dweblogic.security.CustomTrustKeyStorePassPhrase=qaz#1234 " ;
I have an application that on play that use aerospike
in application.conf i have a param that i can rewrite from environments
aerospike.hosts = ["192.168.33.10"]
aerospike.hosts = ${?DS_AEROSPIKE_HOSTS}
how i can set list of hosts in my docker compose file?
version: '3.1'
services:
ds-aerospike-db:
image: aerospike/aerospike-server
restart: always
volumes:
- volume:/opt/aerospike/etc
command: ["--config-file","/opt/aerospike/etc/aerospike.conf"]
ports:
- 3000:3000
dashboard:
image: dashboard:0.1
restart: always
ports:
- 9000:9000
environment:
DS_AEROSPIKE_HOSTS: '["192.168.33.10"]'
this format is an error DS_AEROSPIKE_HOSTS: '["192.168.33.10"]'
I believe you can't pass an array to the ENV variable.
But you can pass it as a string, and then, later, parse string at your application.
environment:
- DS_AEROSPIKE_HOSTS='192.168.33.10,192.168.33.11'
the valid docker-compose.yml syntax is stated at docs
https://docs.docker.com/compose/environment-variables/
I'm not familiar with scala, but I believe you can do something like
aerospike.hosts = ${?DS_AEROSPIKE_HOSTS}.split(',')
You have a couple of options:
You can include a docker.conf file in your Docker build and inject the settings you want into that file. Then you can include the docker.conf file from your application.conf. E.g. add this to your application.conf:
include "docker.conf"
You can use an environment varible to pass a string value (as suggested by Stanislav) but then convert it to a sequence. The idiomatic way to do this is to make a ConfigLoader and then use it to convert a String to a Seq[String]. E.g. something like:
implicit val stringSeqLoader: ConfigLoader[Seq[String]] =
ConfigLoader(_.getString).map(_.split(','))
I'm trying to push an app to Bluemix on a Linux OS. However, the command line returns an error involving the manifest file:
Error reading manifest file:
Expected services to be a list of strings.
Here is the code for the manifest file:
applications:
- name: IdeaSocial
memory: 1024M
instances: 1
host: IdeaSocial
domain: mybluemix.net
path: .
services:
-SQL Database-v5
How do I fix this? Is there a form that the file needs to be in for the current version of Bluemix?
Add quotes around SQL Database-v5 to have it treated as a single string even though there is a space in it. Spaces matter in YAML.
...
services:
- "SQL Database-v5"
The documentation has more information and examples.