supervisor job: spawnerr: can’t find command ‘something’

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, August 05, 2015

Follow me on Twitter as @mattiasgeniar

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!



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.