I love supervisor, an easy to use process controller on Linux. It allows you to configure a process that should always run, similar to god (ruby).
Sometimes though, supervisor isn’t happy. It can throw the following error in your stderr logs.
2015-08-05 15:50:25,311 INFO supervisord started with pid 16450 2015-08-05 15:50:26,312 INFO spawnerr: can't find command './my-worker' 2015-08-05 15:50:27,315 INFO spawnerr: can't find command './my-worker' 2015-08-05 15:50:29,318 INFO spawnerr: can't find command './my-worker' 2015-08-05 15:50:32,322 INFO spawnerr: can't find command './my-worker' 2015-08-05 15:50:32,322 INFO gave up: my-worker entered FATAL state, too many start retries too quickly
Well that’s annoying.
The supervisor config looked decent enough though, nothing wrong to be seen here.
$ cat /etc/supervisor.d/my_worker.ini [program:my_worker] command=./my-worker numprocs=1 numprocs_start=1 directory=/opt/my-worker/bin user=my-worker
It was supposed to su -
to the user defined in the config and run the ./my-worker
from its $HOME
directory. However, that’s not what happens.
When supervisor executes something as a different user, it doesn’t modify the $PATH
variable. In fact, it’s mentioned clearly on the configuration documentation.
[program:x] Section Values
command
If it is relative, the supervisord’s environment $PATH will be searched for the executable.
The tool I wanted to run wasn’t in supervisor’s $PATH
though.
To fix this, it’s just a matter of making all commands in your configurations use absolute paths – instead of relative paths. Configure the full path in the command=
config parameter, and supervisor will happily start your configuration.
This’ll work:
$ cat /etc/supervisor.d/my_worker.ini [program:my_worker] command=/opt/my-worker/bin/my-worker numprocs=1 numprocs_start=1 directory=/opt/my-worker/bin user=my-worker
Hope it helps you one day too!