简体   繁体   中英

How can I set the PATH for supervisord so it finds the executables

I'm trying to setup supervisor.conf . One of my apps requires node.js, but node is not installed system wise. Also, because it needs to bind to port 80 it need to run as root. How can I modify the PATH variable so that supervisord can find the node executable (which is located in a directory) and run the node.js app.


I'm trying to do it like this

[supervisord]
environment=PATH=/path/to/where/node/executable/is

[program:web]
command=node web.js -c config.json

This fails with

2011-08-25 16:49:29,494 INFO spawnerr: can't find command 'node'

You can add it in the command using env:

[program:web]
command=env PATH="/path/to/where/node/executable/is" node web.js -c config.json

It seems environment does not work on some cases.

A pattern I've started using with supervisor (which is similar to zenbeni's) is to use a shell script to start whichever program I'm running which allows setup of environment variables etc.

eg

#!/bin/sh
export EXAMPLE_VARIABLE=something
export PYTHONPATH=/something
export PATH=$PATH:/somewhere/else
exec python somescript.py

The use of 'exec' is important. It replaces /bin/sh with the program being executed instead of spawning it as a child. This means that there aren't any additional processes around, and also signals work as expected.

The (small) advantage of this over zenbeni's method is that when updating environment variables etc it only takes a supervisor restart, ie no reread/update etc is required. This advantage gets bigger when using an event listener if you hit the same bug I did (full restart of supervisor to update event listener environment variables).

You can just set the absolute path to the command:

[program:web]
command=/path/to/where/node/executable/is/node web.js -c config.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM