MaxLunar
MaxLunar

Reputation: 663

Running daemonized Bottle app with ability to change server

What problem I have:

I need to properly launch my Bottle application in daemon mode, while keeping all features of bottle.run() command.

What did I tried:

  1. Using BottleDaemon. It doesn't suit me, because I need to change server variable (and perharps more actions with bottle.run() in future), but bottledaemon.daemon_run() doesn't support it.
  2. daemonize.py. Process exits without any logs and stdout/stderr.
  3. Putting my Bottle app into supervisor. My shell account doesn't have access to root or sudo, and I think that's why it drops me a Permission denied error on subprocess.Popen.

upd. Here's traceback when I try to launch bottle app via supervisor

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

It still runs perfectly without 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.

Is theres another way to fix my problem? Thanks in advance.

Upvotes: 1

Views: 481

Answers (1)

ron rothman
ron rothman

Reputation: 18148

(Answer is based on additional info from OP in comments.)

To run your server in the background and have it not exit when you log out, you can use nohup:

nohup python myscript.py &

Upvotes: 1

Related Questions