Package: django-windows-tools
django-windows-tools is a Django application providing management commands to host Django projects in Windows environments.It provides management commands allowing to:Host a Django application behind IIS as a FastCGI application (requires IIS 7 and Up).Run Celery and Celery Beat background processes as a Windows Service.It requires Django >= 1.4 and pywin32.Compatibility notesdjango-windows-tools 0.1.3 is the last version to work with Django <= 1.7thewin_fcgipart is known to work with Django versions up to 1.11 and Python 3.6 (django-windows-tools 0.2 needed), and works with IIS up to version 10installing services with newer versions of Django and Python 3 is not tested and may not work (see also the open issues)newer Celery versions cannot be installed as a service as described (see #19)The following gives a Quick overview of the project. For more information, please
read theProject documentation.Installation and ConfigurationYou install the application with the command:pip install django-windows-toolsOr you may install the latest development version for more fixed bugs:pip install git+https://github.com/antoinemartin/django-windows-tools@masterEnable thedjango_windows_toolsapplication to be able to use the management commands. Add the app to
the project’s list insettings.py:INSTALLED_APPS += (
    'django_windows_tools',
)FastCGI ConfigurationPre-requisitesOn the host machine, you need to have :IIS 7 or better installed and running.TheCGImodule installed.To host your Django project underIISwith the bindingwww.mydjangoapp.com,
you need first to collect your static files with the command:D:\sites\mydjangoapp> python manage.py collectstaticAnd then run the following command with Administrator privileges :D:\sites\mydjangoapp> python manage.py winfcgi_install --binding=http://www.mydjangoapp.com:80The command will do the following:Create the FastCGI application to serve your Django application dynamic content.Create a site namemydjangoappwith thewww.mydjangoapp.combinding pointing to the root of your project.Install aweb.configfile in the root of the project that handles the
redirection of requests to the Django application.Create if needed a virtual directory to handle the serving of your static files throughIIS.To remove the site created with the preceding command, type:D:\sites\mydjangoapp> python manage.py winfcgi_install --deletethewinfcgi_installcommand provides numerous options. To list them, type:D:\sites\mydjangoapp> python help winfcgi_installMore information on how the configuration is done is provided in
thisBlog post.Running Celery or other Background commands as a Windows ServiceWith the application installed, on the root of your project, type the following command:D:\sites\mydjangoapp> python manage.py winservice_installIt will create two files,service.pyandservice.iniin the
root directory of your project. The first one will help you install,
run and remove the Windows Service. Ther later one contain the list of
the management commands that will be run by the Windows Service.ConfigurationTheservice.iniis a configuration file that looks like the following:[services]
# Services to be run on all machines
run=celeryd
clean=d:\logs\celery.log

[BEATSERVER]
# There should be only one machine with the celerybeat service
run=celeryd celerybeat
clean=d:\logs\celerybeat.pid;d:\logs\beat.log;d:\logs\celery.log

[celeryd]
command=celeryd
parameters=-f d:\logs\celery.log -l info

[celerybeat]
command=celerybeat
parameters=-f d:\logs\beat.log -l info --pidfile=d:\logs\celerybeat.pid

[runserver]
# Runs the debug server and listen on port 8000
# This one is just an example to show that any manage command can be used
command=runserver
parameters=--noreload --insecure 0.0.0.0:8000

[log]
filename=d:\logs\service.log
level=INFOTheservicessection contains :The list of background commands to run in therundirective.The list of files to delete when refreshed or stopped in thecleandirective.You can have severalservicessections in the same configuration file
for different host servers. The Windows Service will try to find the section which name
matches the name of the current server and will fallback to theservicessection if it
does not find it. This allows you to deploy the same configuration file on serveral
machines but only have one machine run the celery beat background process. In the preceding
configuration, only the server namedBEATSERVERwill run thecelerybeatcommand.
The other ones will only run thecelerydcommand.For each command name specified in therundirective, there must be a matching configuration
section. The section contains two directives:commandspecifies themanage.pycommand to run.parametersspecifies the parameters to the command.In the previous configuration file, thecelerydconfiguration will spawn a process
that will run the same command as :D:\sites\mydjangoapp> python manage.py celeryd -f d:\logs\celery.log -l infoLastly, thelogsection defines the log level and the the log destination file
for the Windows Service.Installation and startThe windows service is installed with the following command (run with
Administrator privileges) :D:\sites\mydjangoapp> python service.py --startup=auto installIt is started and stopped with the commands:D:\sites\mydjangoapp> python service.py start
D:\sites\mydjangoapp> python service.py stopIt can be removed with the following commands:D:\sites\mydjangoapp> python service.py removeThe Windows Service monitor changes to theservice.iniconfiguration
file. In case it is modified, the service does the following:Stop the background processes.Reread the configuration file.Start the background processes.CustomizationThewinservice_installmanagement command provides several options
allowing to customize the name of the web service or of the script name.
To obtain information about them, type:D:\sites\mydjangoapp> python manage.py help winservice_install