开发者

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

开发者 https://www.devze.com 2023-03-30 22:42 出处:网络
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 PAT

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.

e.g.

#!/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, i.e. 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
0

精彩评论

暂无评论...
验证码 换一张
取 消