node.js child_process.spawn ENOENT error - only under supervisord

老子叫甜甜 提交于 2019-12-20 04:44:18

问题


I'm running a command with Node.js using child_process.spawn:

#!/usr/bin/js

var spawn = require("child_process").spawn;

var stockfish = spawn("stockfish");

This works fine using $js spawntest.js from the command line; it just hangs like you would expect because the subcommand is waiting for input.

When I set this script up as a supervisord program, however, it fails:

$ sudo supervisorctl start spawntest
spawntest: ERROR (abnormal termination)

Here is the contents of the stderror output log that supervisor keeps in /var/log/supervisor/spawntest-stderr---supervisor-RyULL0.log:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

The supervisorctl program is configured like this:

[program:spawntest]
command=/home/gus/dev/spawntest.js
autostart=false
autorestart=false
user=gus

Why is this failing only under Supervisor? Are there any Node.js modules/global variables etc I can use to see what the differences are between invoking a script directly and through Supervisor?

来源:https://stackoverflow.com/questions/24496015/node-js-child-process-spawn-enoent-error-only-under-supervisord

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!