Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 356
bbrodriges Avatar asked May 06 '26 23:05

bbrodriges


2 Answers

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.

like image 61
brice Avatar answered May 08 '26 13:05

brice


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
like image 40
A.V Avatar answered May 08 '26 13:05

A.V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!