Supervisor / supervisor

Supervisor process control system for Unix (supervisord)
http://supervisord.org
Other
8.46k stars 1.24k forks source link

How to evaluate process command without substituting environment variables? #1526

Closed jshah closed 2 years ago

jshah commented 2 years ago

I have a command (below), and I don't want to have supervisor try to substitute asctime, levelname and message with env vars.

command=/usr/local/bin/rq worker default --log-level '%(asctime)s - %(levelname)s - %(message)s'

Is there a way I can have supervisor just run the command as is without trying to substitute env vars?

Error when running

Error: Format string '"/usr/local/bin/rq worker default --log-level \'%(asctime)s - %(levelname)s - %(message)s\'"' for 'program:rq-worker.command' contains names ('asctime') which cannot be expanded.
mnaberez commented 2 years ago

Is there a way I can have supervisor just run the command as is without trying to substitute env vars?

Escape the % with a %.

$ cat supervisord.conf
[supervisord]
loglevel = debug

[program:dumpargs]
command = python3 dumpargs.py worker default --log-level '%%(asctime)s - %%(levelname)s - %%(message)s'
startsecs = 0
autorestart = false

$ cat dumpargs.py 
import sys
print(sys.argv)

$ supervisord --version
4.2.4

$ supervisord -n -c supervisord.conf 
2022-07-12 13:41:33,131 INFO supervisord started with pid 1284
2022-07-12 13:41:34,136 INFO spawned: 'dumpargs' with pid 1286
2022-07-12 13:41:34,190 DEBG 'dumpargs' stdout output:
['dumpargs.py', 'worker', 'default', '--log-level', '%(asctime)s - %(levelname)s - %(message)s']