为什么新手不能停止我的节点服务器?

我有一个超级简单的testing节点服务器

# server.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8080, '127.0.0.1'); console.log('Server running at http://127.0.0.1:8080/'); 

我有一个简单的新贵脚本/etc/init/myapp.conf

 description "myapp" author "me" start on started stop on shutdown exec /usr/bin/node /path/to/server.js 

开始工作很好

 sudo start myapp myapp start/running, process 2518 

但停止只是重新启动应用程序

 sudo stop myapp myapp start/running, process 2527 

我没有得到什么?

PS:我使用的是Ubuntu 14.04

我在Upstart工作中看到的一个问题就是节的start on 。 你的工作开始的事件是started事件。 通过阅读暴发事件的手册页,人们发现当Upstart开始任何工作时,启动的事件就会被发射出去。 这不是你想要的。 而应使用诸如runlevel [2345]类的事件,以便在所有多用户运行级别上启动您的应用程序。 这应该清除你的问题。