【问题标题】:running node.js server using upstart causes 'terminated with status 127' on 'ubuntu 10.04'使用 upstart 运行 node.js 服务器会导致“ubuntu 10.04”上的“以状态 127 终止”
【发布时间】:2013-01-19 12:18:27
【问题描述】:

我已经为 ubuntu 编写了一个 upstart 脚本来手动或在启动时启动我的 node.js 服务器。但它总是以状态 127 终止,我找不到更多关于出了什么问题的信息。如果我手动执行它,那么它可以工作,并且我还在 ubuntu 12.10 上对其进行了测试,它也可以工作......它只是无法在我正在使用的生产服务器 ubuntu 10.04 上工作。

脚本:

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

知道在哪里可以找到有关状态 127 的更多信息吗?或者我该如何解决这个问题?我查看了 /var/log/daemon.log 和 /var/log/syslog.log .. 但除了“主进程 (29520) 以状态 127 终止”之外没有相关信息。

亲切的问候,

大安

【问题讨论】:

标签: node.js ubuntu-10.04 upstart


【解决方案1】:

bash 中的 127 表示:“找不到命令”、非法命令、$PATH 可能存在问题或拼写错误。

来源:http://tldp.org/LDP/abs/html/exitcodes.html

这可能是服务器故障的问题,因为它与 bash 相关,但这个问题/答案可能会对您有所帮助:

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

【讨论】:

  • 好的,我将启动命令提取到一个单独的 bash 脚本中,我从 upstart 脚本中执行该脚本,然后它似乎可以工作了......
【解决方案2】:

有相同的错误消息,在自定义 upstart 日志中跟踪它失败了 /usr/bin/env: node: No such file or directory,这是我的修复:

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

【讨论】:

    【解决方案3】:

    有这个问题。我正在 ubuntu 服务器 14.04 中使用 gunicorn 部署 Web 应用程序。 将您的核心指令移至 bash 脚本。并记住使脚本可执行。我忽略了使 bash 脚本可执行,所以我得到了 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/
    

    然后是我的 bash 脚本

    #!/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 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-15
      • 2012-10-05
      • 2012-01-27
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      相关资源
      最近更新 更多