マイン マイン
システム開発


Run Python as service

Run Python as service

Using Python event-driven such as Tornado, we can develop a great system as an alternative to NodeJS technology. However, keep it running as a system service is not built-in. We have to managed ourself to do this.

Luckily there is Supervisord http://supervisord.org , written in Python, and greatly get our service in Python up. It can serve not only Python, but almost every program.
The installation is trivial in Ubuntu with apt-get install supervisor.
Other distro can use pip install supervisor. Below is the case of Ubuntu server installation.

We need to create a conf file at /etc/supervisor/conf.d/, as example a-svc.conf (noted the file extension)

Then bring all up running with sudo service supervisor restart
Assume our service running at 9876
We can test using curl http://127.0.0.1:9876/a-query

To public this service, we can add some kind of config in Nginx:

We have it done nicely!

この記事を書いた人
マイン

ベトナム生まれの開発者、私はPHPとかCSS/JS/HTML/Linux server経験があります。ひまの時に日本語は勉強します。

札幌市中央区北3条西26丁目3-8 N2ビル3F 〒064-0823 TEL:011-640-5437 FAX:011-640-5434
東京都港区六本木4丁目2-35 アーバンスタイル六本木三河台2F 〒106-0032 TEL:03-5772-1414 FAX:03-5772-1404
NADIA BANGKOK / 240 soi 52 Romklao Road Ladkrabang Bangkok 10520 Thailand
NADIA HANOI / 5F, SIMCO Bld., 28 Pham Hung, Ha Noi, Viet Nam
PAGETOP
ナディアFacebookページ株式会社ナディア|Nations Media Design Nadia
PAGE TOP ↑