当我注销时,Upstart 服务停止

当我注销时,Upstart 服务停止

我编写了一个 upstart 脚本,希望它在服务器启动时运行,但它却没有运行。当我调用 时sudo start wiki,它会运行,其中wiki是我的服务名称,但是当我注销时,它会停止运行。

这是脚本:

description "run the noplwiki web service"

start on runlevel [2345]

script
    logfile="/var/log/wiki.log"
    source="/home/matt/python/noplwiki/"

    exec >> ${logfile} 2>&1

    . /home/matt/.virtualenvs/noplwiki/bin/activate

    cd ${source}
    exec python wiki.py
end script

这是我登录后启动它、向服务请求某些内容然后注销时的日志文件:

[20/Oct/2012:18:27:28] ENGINE Listening for SIGHUP.
[20/Oct/2012:18:27:28] ENGINE Listening for SIGTERM.
[20/Oct/2012:18:27:28] ENGINE Listening for SIGUSR1.
[20/Oct/2012:18:27:28] ENGINE Bus STARTING
[20/Oct/2012:18:27:28] ENGINE Started monitor thread '_TimeoutMonitor'.
[20/Oct/2012:18:27:28] ENGINE Started monitor thread 'Autoreloader'.
[20/Oct/2012:18:27:29] ENGINE Serving on 0.0.0.0:8080
[20/Oct/2012:18:27:29] ENGINE Bus STARTED
192.168.1.64 - - [20/Oct/2012:18:27:41] "GET / HTTP/1.1" 200 699 "" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0"
192.168.1.64 - - [20/Oct/2012:18:27:41] "GET /js/index.js HTTP/1.1" 304 - "http://192.168.1.66:8080/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0"
[20/Oct/2012:18:27:51] ENGINE Restarting because /home/matt/.virtualenvs/noplwiki/local/lib/python2.7/site-packages/pymongo/helpers.py changed.
[20/Oct/2012:18:27:51] ENGINE Stopped thread 'Autoreloader'.
[20/Oct/2012:18:27:51] ENGINE Bus STOPPING
[20/Oct/2012:18:27:51] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down
[20/Oct/2012:18:27:51] ENGINE Stopped thread '_TimeoutMonitor'.
[20/Oct/2012:18:27:51] ENGINE Bus STOPPED
[20/Oct/2012:18:27:51] ENGINE Bus EXITING
[20/Oct/2012:18:27:51] ENGINE Bus EXITED
[20/Oct/2012:18:27:51] ENGINE Waiting for child threads to terminate...
[20/Oct/2012:18:27:51] ENGINE Re-spawning wiki.py
Traceback (most recent call last):
  File "wiki.py", line 46, in <module>
    cherrypy.quickstart(Server(), '/', conf)
  File "/home/matt/.virtualenvs/noplwiki/local/lib/python2.7/site-packages/cherrypy/__init__.py", line 161, in quickstart
  File "/home/matt/.virtualenvs/noplwiki/local/lib/python2.7/site-packages/cherrypy/process/wspbus.py", line 332, in block
  File "/home/matt/.virtualenvs/noplwiki/local/lib/python2.7/site-packages/cherrypy/process/wspbus.py", line 376, in _do_execv
OSError: [Errno 2] No such file or directory: '/home/matt/python/noplwiki'

为什么我注销后它就关闭了?据我所知,helpers.py 文件没有改变。

-rw-rw-r-- 1 matt matt 7350 Oct 15 20:32 /home/matt/.virtualenvs/noplwiki/local/lib/python2.7/site-packages/pymongo/helpers.py

答案1

正如@Tuminoid猜到了楼主意识到了在他的评论中,他的主目录是加密的。

现在@Tuminoid 正确指出在他的评论中解决这个问题最简单的方法是将服务运行所需的文件从主目录移动到任何始终可用的位置,而不仅仅是在特定用户登录并解密其主目录时。

相关内容