3

你能在 ubuntu 上为 nodejs 推荐一个新贵的配置文件吗?我找到了以下教程:http ://howtonode.org/deploying-node-upstart-monit但它似乎很旧。

4

1 回答 1

1

我有一个小 shell 脚本来创建我的配置文件。

create_upstart() {
  project=$1
  file=$2
  conf="/etc/init/${project}_${file}.conf"

  cat > $conf << EOF
  #!upstart

  description "Node Process - $1"
  author      "Geert Pasteels"

  respawn

  start on (local-filesystems and net-device-up IFACE=eth0)
  stop  on shutdown

  script
    export NODE_ENV="production"
    export PORT="3001"
    exec /usr/bin/node /var/www/$project/current/$file.js >> /var/www/$project/shared/logs/$file 2>&1
  end script
EOF

  echo $conf

  # Restart upstart script
  stop ${project}_${file}
  start ${project}_${file}
  echo Restarted ${project}_${file}
}

create_upstart "$1" "$2"

我将它与TJ 的 deploy结合使用。所以在我的发布后部署钩子中我做startup app file.

于 2012-11-06T17:53:10.857 回答