시작-중지-데몬이 예상대로 작동하지 않습니다

시작-중지-데몬이 예상대로 작동하지 않습니다

start-stop-daemon이 아래 스크립트를 실행하지 않는 이유를 알 수 없습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? start-stop-daemon은 --test 플래그를 사용할 때 노드가 시작된다고 보고하지만 실제로 실행하면 프로세스가 시작되지 않습니다.

root@server:~# cat /var/www/a/app.js
var http = require("http")
var fs = require("fs")

fs.writeFileSync("app.pid", process.pid)

http.createServer(function(req, res)
{
    res.writeHead(200, {"Content-Type": "text/plain"})
    res.end("Test")
}).listen(3000)

console.log("App A is running, PID", process.pid)
root@server:~# node /var/www/a/app.js
App A is running, PID 18517
^Z
[1]+  Stopped                 node /var/www/a/app.js
root@server:~# pidof node
18517
root@server:~# kill -9 `pidof node`
root@server:~# fg
-su: fg: job has terminated
[1]+  Killed                  node /var/www/a/app.js
root@server:~# rm /var/www/a/app.pid
root@server:~# start-stop-daemon --start --pidfile /var/www/a/app.pid --chdir /var/www/a --chuid www-data:www-data --background --exec /opt/iojs/bin/node app.js --test
Would start /opt/iojs/bin/node app.js  (as user www-data[33], and group www-data[33]).
root@server:~# start-stop-daemon --start --pidfile /var/www/a/app.pid --chdir /var/www/a --chuid www-data:www-data --background --exec /opt/iojs/bin/node app.js
root@server:~# pidof node
root@server:~# start-stop-daemon --start --pidfile /var/www/a/app.pid --chdir /var/www/a --chuid www-data:www-data --background --exec app.js --test
Would start app.js  (as user www-data[33], and group www-data[33]).

답변1

start-stop-daemon start명령은 --exec실행할 바이너리 파일을 결정하는 데 사용됩니다(귀하의 경우 /opt/iojs/bin/node). 이 명령에 대한 인수를 표시하려면 --(귀하의 경우 àpp.js) 를 추가해야 합니다.

따라서 다음과 같이 호출해야 합니다.

start-stop-daemon --start --pidfile /var/www/a/app.pid --chdir /var/www/a --chuid www-data:www-data --background --exec /opt/iojs/bin/node -- app.js

이것이 당신의 문제를 해결해주기를 바랍니다

관련 정보