运行 能够更改服务器的守护进程 Bottle 应用程序

Running daemonized Bottle app with ability to change server

我有什么问题:

我需要正确地在守护进程模式下启动我的 Bottle 应用程序,同时保持 bottle.run() 命令的 所有 功能。

我尝试了什么:

  1. 使用BottleDaemon。它不适合我,因为我需要更改服务器变量(并且将来可能会使用 bottle.run() 执行更多操作),但 bottledaemon.daemon_run() 不支持它。
  2. daemonize.py。进程在没有任何日志的情况下退出并且 stdout/stderr.
  3. 将我的 Bottle 应用放入 supervisor。我的 shell 帐户无法访问 root 或 sudo,我想这就是为什么它在 subprocess.Popen.
  4. 上给我一个 Permission denied 错误

更新。这是我尝试通过 supervisor

启动 Bottle 应用程序时的回溯
Traceback (most recent call last):
  File "/home/maxlunar/bottle/app.py", line 20, in <module>
    run(server='tornado', host='xxxx', port=xxxxx, reloader=True)
  File "/home/maxlunar/.local/lib/python3.5/site-packages/bottle.py", line 3079, in run
    p = subprocess.Popen(args, env=environ)
  File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
    raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied

没有supervisor它仍然可以完美运行:

(bottle) maxlunar@Lydia:bottle$ python app.py
Bottle v0.12.13 server starting up (using TornadoServer())...
Listening on http://xxxxx:xxxxx/
Hit Ctrl-C to quit.

还有其他方法可以解决我的问题吗?提前致谢。

(答案基于评论中来自 OP 的附加信息。)

为了运行你的服务器在后台并且当你注销时退出,你可以使用nohup:

nohup python myscript.py &