Tuesday, June 2, 2009

Deploying python web application on Windows

There are many deployment scenarios with Python web applications. Without diving into all the options I'll suppose part of your deployment is utilizing Paste Deployment (http://pythonpaste.org/deploy/) . To test and develop your application you use "paster serve some_name.ini". Now to setup the application so that it runs after log off or restart you need a customized Windows service.

There are a couple of recipes around to achieve this but, you have to copy and paste some code and hardcode the name and config file into it. I've put together a little tool which helps creating windows services, based on arbitrary configuration parameters.

First, install the tool:

easy_install WsgiWinService

This adds the wsgisvc.exe into your scripts directory.

Second, you have to extend your *.ini file with a [winservice] section. The list of options you can use:
svc_name
svc_display_name
svc_description
virtual_env

Only the svc_name option is mandatory. If you don't use svc_display_name or svc_decription sensible default will be made up. The minimal configuration you need to add looks like this:

[winservice]
svc_name = svc1

Third, install the service:

wsgisvc -c some_name.ini install

This adds the service "svc1" to your system. You can check it out under display name "svc1 Paste Service" through Administrative Tools -> Services. To start the service you can either use that or command line:

wsgisvc -c some_name.ini start

And the last thing, to list display names of all installed Paste services:

wsgisvc list

If this helps somebody, let me know please.

2 comments:

  1. Certsout.com provides authentic IT Certification exams preparation material guaranteed to make you pass in the first attempt, this is the right platform where you can get exact 700-905 dumps questions answers.

    ReplyDelete
  2. Casino (Hotel, Slots, Bars, Restaurants) - Mapyro
    Information 원주 출장안마 and reviews of Casino (Hotel, 하남 출장샵 Slots, Bars, Restaurants, 경상남도 출장안마 Restaurants) located in Las Vegas, 광주광역 출장샵 Nevada 89135, United States. 양주 출장마사지

    ReplyDelete