Supervisord – 在supervisord.conf中使用变量INSIDE
转而使用
supervisod作为过程控制系统.
我的supervisord.conf中有一个LONG和重复的环境配置,为很多进程设置了很多环境变量.我需要在一个地方定义并重用它,以保持配置DRY和可维护.这是可能与主管和如何? 编辑:非干配置的示例 [program:node-app1] command=node /home/ubuntu/server/node-app1/app.js directory=/home/ubuntu/server/node-app1 autostart=true autorestart=true stderr_logfile=/home/ubuntu/supervisor/node_app1/err.log stdout_logfile=/home/ubuntu/supervisor/node_app1/out.log user=ubuntu priority=998 startretries=20 ENVIRONMENT=BROKER_URL="amqp://user:password@path.to.rabbit:5672",NODE_ENV=envName,MONGO_URL="mongodb://path.to.mongo:27017",BASE_PUBLIC_API="http:path.to.api",REDIS_URL="redis://path.to.redis:6379",BACKEND_URL="https://path.to.backend",CHARTS_URL="https://path.to.charts" [program:node-app2] command=node /home/ubuntu/server/node-app2/app.js directory=/home/ubuntu/server/node-app2 autostart=true autorestart=true stderr_logfile=/home/ubuntu/supervisor/node_app2/err.log stdout_logfile=/home/ubuntu/supervisor/node_app2/out.log user=ubuntu priority=20 startretries=20 ENVIRONMENT=BROKER_URL="amqp://user:password@path.to.rabbit:5672",CHARTS_URL="https://path.to.charts" 可以共享的内容:环境,日志的基本目录(每个应用程序只会更改结束),常见变量如startsecs.等等 解决方法
选项
通过supervisord继承: 只要您使用version 3.0a10或更高版本,就可以在[supervisord]环境中设置环境变量,它们将位于supervisord管理下的所有进程的环境中. [supervisord] ... environment=FAVORITE_VENTURE="RUSTY",FAVORITE_COLOR="RED" 使用继承自Shell的Variables supervisord Supervisord还有一个用于解释环境变量的 例如,如果您使用init脚本启动supervisord并且是基于debian的系统(即Ubuntu),那么您可以从/ etc / default / supervisor中的以下内容开始: export SUPERVISOR_INCLUDES="main.conf test.conf" export MAIN_RETRY_COUNT=2 export TEST_RETY_COUNT=1 MONGO_BASE="MONGO_URL=mongodb://path.to.mongo" MAIN_MONGO_URL="${MONGO_BASE}:27017" TEST_MONGO_URL="${MONGO_BASE}:27018" export MAIN_ENV="${MAIN_MONGO_URL},OTHER_THING="Another thing with escaped quoting"" export TEST_ENV=.. 然后在配置中使用它们: ; supvervisord.conf [includes] files= %(here)s/subdir/other.conf %(ENV_SUPERVISOR_INCLUDES)s ; main.conf [group:main] ... [program:mainbackend] startretries=%(ENV_MAIN_RETRY_COUNT)s environment=%(ENV_MAIN_ENV)s 如果用户可以sudo并直接调用supervisord,这种方法不能很好地工作,因为sudo既剥离用户环境又不运行传统的shell init脚本.但你可以在root的.bashrc中找到/ etc / default / supervisor并使用sudo bash -c“supervisord ..”或在调用supervisord之前获取它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |