I'm currently developing a bottle app within virtualenv. I intend to serve it using bjoern WSGI server (but that probably doesn't matter too much). I also intend to serve the app with a lighty or nginx reverse proxy. Anyhow, can the app be run from within its own virtualenv as a system service? And if so, how would one go about it?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
According to my experience, I suggest that you can use Supervisord to run your web server as daemon service. Although you can write some Linux service scripts in /etc/init.d, but they are really difficult to do it correctly. Here is an example init.d script for nginx to run it as a service in Ubuntu. You don't want to write one, do you?
To run a python server which depends on virtualenv as daemon service with supervisord, here is the configuration I am using in a production environment.
You can use /path/to/virtualenv/bin/python to run your own python script in the command field. And, to run the supervisord on start-up, you can write crontab like this in your root account:
Of course, if you don't have port numbers lower than 1024 to open, you can write this start-up crontab in a non-privilege account.