bbrodriges
bbrodriges

Reputation: 713

python - daemonize bottlepy script

I'm using a Bootle Python Web Framework to develop webapps on Ubuntu. Is there any effective way to daemonize script that starts default bottlepy webserver?

Thank you.

UPD: Now I'm using Supervisord for this purposes.

Upvotes: 3

Views: 3397

Answers (3)

A.V
A.V

Reputation: 41

On ubuntu I use following steps:

  1. Remember to insert full path to templates into bottle.TEMPLATE_PATH
  2. Make script executable (chmod +x <script_name>)
  3. Make symlink to script w/o .py extension
  4. Navigate to /etc/init.d and copy skeleton to <script_symlink_name>
  5. Modify new init script
    • Change NAME to <script_symlink_name>
    • Change DAEMON to <path_to_script_symlink>
    • Change DAEMON_ARGS to ""
    • Change DESCRIPTION
    • Add "--background" switch to start-stop-daemon (line w/o "--test" switch) in do_start()
  6. Make init script executabe
  7. Test via "service <script name> start"
  8. Set autostart: update-rc.d <script-name> defaults

Upvotes: 3

Darek
Darek

Reputation: 2921

You can use supervisord or monit to start/stop and restart the app.

Upvotes: 0

brice
brice

Reputation: 25039

As reclosedev mentions, nohup ... & will work without fuss.

You can also use something like daemonize Which has more options than using nohup.

Personally I run the following while developing with autoreload switched on:

while true; do python app.py ; done

which restarts the server if I write something stupid. Other solutions will force you to restart your server for a syntax error.

Deployment happens behind apache or lighttpd.

Upvotes: 4

Related Questions