running node.js server using upstart causes 'terminated with status 127' on 'ubuntu 10.04'

寵の児 提交于 2019-11-28 07:41:57

问题


i have written an upstart script for ubuntu to launch my node.js server manually or on startup. But it always terminates with status 127 and i can't find more information about what is going wrong. If i execute it manually then it works and i also tested it on ubuntu 12.10 where it also works ... it only fails to work on ubuntu 10.04 which is the production server i'm using.

The script:

description ""
author      ""

start on started mountall
stop on shutdown
respawn
respawn limit 20 5

# Max open files are @ 1024 by default. Bit few.
limit nofile 32768 32768

env HOME=/home/projects/<project_name>/data/current

script
    export HOME=$HOME
    chdir $HOME
    exec sudo -u <user_to_launch_the_script> /usr/bin/node /home/projects/<project_name>/data/current/server.js 2>&1 >> /var/log/node.log
end script

any idea where to find more information about the status 127? Or how i can fix this? i have looked in /var/log/daemon.log and in /var/log/syslog.log .. but there is no relevant info except for 'main process (29520) terminated with status 127'.

kind regards,

Daan


回答1:


127 in bash means: "command not found", illegal_command, possible problem with $PATH or a typo.

Source: http://tldp.org/LDP/abs/html/exitcodes.html

This might be a question for server fault, as it is bash related, but this question / answer might help you:

https://serverfault.com/questions/277706/cron-fails-with-exit-status-127




回答2:


Had the same error messages, tracked it down in custom upstart log that failed with /usr/bin/env: node: No such file or directory, this was my fix:

https://github.com/joyent/node/issues/3911




回答3:


Had this issue. I am deploying web app with gunicorn in ubuntu server 14.04. Move your core instructions to a bash script. And remember to make the script executable. I had neglected to make the bash script executable and so I was getting the 127.

description "Gunicorn  app running myproject"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

setuid <user> 
setgid <group>

exec bash /path/to/bash/script/

then my bash script

#!/bin/bash
# description "bash script that handles loading env and running gunicorn"

# load up the project's virtualenv 
source /path/to/virtualenv/bin/activate

# minimal settings 
exec gunicorn app:app 


来源:https://stackoverflow.com/questions/14692843/running-node-js-server-using-upstart-causes-terminated-with-status-127-on-ubu

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