Windows PROD
Run Automail on a Windows server for PROD and UAT usage.
Last updated
Run Automail on a Windows server for PROD and UAT usage.
Last updated
Good to know: on Windows, the Automail web application runs on IIS and the workflows as scheduled tasks in the Task Scheduler.
Install the following software on the server:
Python 3.9 or later (official 64-bit version installed in C:\Program Files\Python).
Notepad++ for editing settings.py.
Git and GitHub Desktop.
MySQL Community Server (version 8.0) and MySQL Workbench.
on the server with the CGI feature activated. The IIS installation is done via the Server Manager.
The below installation is done in the C drive. If the server has a separate drive for storing the data use that drive instead.
The following steps are the same as for the local DEV installation:
Create a Lineverge folder in C:\Lineverge\Automail Forks\[forked repo name], with the sub-folders ve, repo, backup, and staging
Navigate to ve and create a virtual environment with virtualenv automail
Activate the ve with automail\Scripts\activate.bat
Navigate to repo and clone the forked repo with git clone https://github.com/Lineverge/[forked repo name].git .
(don't forget the dot!)
Navigate to C:\Lineverge\Automail Forks\[forked repo name]\software and run pip install -r requirements.txt
Create a backup of your local database and restore it in MySQL Workbench
Navigate to C:\Lineverge\Automail Forks\[forked repo name]\software\project
Create settings.py in the project folder and adjust the paths and database constants to match the server.
Run python automail.py runserver
to test that the installation was successful.
The following steps are IIS-specific:
Run python automail.py collectstatic --noinput
to move all static files in a folder that will be used by IIS to server static content to the users (HTML, CSS, JS, images, etc.).
Run pip install wfastcgi
and move the wfastcgi.py file from site-packages in the ve to C:\Lineverge\Automail Forks\[forked repo name]\staging\server.
Open the IIS Manager.
Access the FastCGI Settings.
Click Add Application and set the Full Path, Arguments, and Environment Variables.
Full Path: C:\Lineverge\Automail Forks\[forked repo name]\ve\Scripts\python.exe Arguments: C:\Lineverge\Automail Forks\[forked repo name]\staging\server\wfastcgi.py
Collection: DJANGO_SETTINGS_MODULE: project.settings PYTHONPATH: C:\Lineverge\Automail Forks\[forked repo name]\repo\software WSGI_HANDLER: django.core.wsgi.get_wsgi_application()
Go to Sites and Add Website.
Site name: [forked repo name] Physical path: C:\Lineverge\Automail Forks[forked repo name]\repo\software Host name: [Automail instance domain] (e.g. test.lineverge.com)
Click on the newly created site, then double-click on Handler Mappings, then Add Module Mapping... under Actions.
Input all parameters.
Request path: * Module: FastCgiModule Executable: "C:\Lineverge\Automail Forks[forked repo name]\ve\Scripts\python.exe"|"C:\Lineverge\Automail Forks[forked repo name]\staging\server\wfastcgi.py" Name: [forked repo name] Requests Restrictions: Uncheck Invoke handler only if request is mapped to: checkbox and click OK
Click OK, then No in the popup.
Right-click on the site, then Add Virtual Directory...
Set the parameters for a virtual directory and click OK.
Alias: static Physical path: C:\Lineverge\Automail Forks[forked repo name]\repo\software\static
Unfold the site, click on the static folder, then double-click on Handler Mapping.
Select View Ordered List...
Then move StaticFile to the top using the Move Up button under Actions.
Go to C:\Lineverge\Automail Forks\[forked repo name]\repo\software and make a copy of the web.config file.
Replace the current web.config file with the web.config in C:\Lineverge\Automail Forks\[forked repo name]\repo\deployment\iis\web.config.
Click on the site. Then Start under Manage Website.
Automail will now be accessible at online under hostname defined above [Automail instance domain] (e.g. test.lineverge.com).
Any change in the source code of the fork needs to be pulled on the server using git pull
.
If the change involves new migration files, then these need to be migrated to the production database by running python automail.py migrate
from the project folder.
If the change involves new or changed static files, then these need to be moved to the production static folder by running python automail.py collectstatic --noinput
from the project folder.
Background jobs are scheduled through the Task Scheduler in Windows.
Scheduled tasks can be created programmatically from the CMD using the schtasks
command.
In this example schtasks
command, the parameters are as follows:
/create
: Creates a new scheduled task.
/tn "Automail-LV-Test\automail_test"
: Sets the task name to "Automail-LV-Test\automail_test".
/sc WEEKLY
: Sets the schedule type to WEEKLY.
/d MON
: Sets the day of the week when the task runs to Monday.
/st 09:00
: Sets the start time of the task to 9:00 AM.
/tr "C:\Lineverge\Automail Forks\[forked repo name]\ve\Scripts\python.exe C:\Lineverge\Automail Forks[forked repo name]\repo\software\project\automail_test.py"
: Sets the command to execute for the task, which runs a Python script using a specified Python interpreter.
/RU automail
: Specifies the user account under which the task runs as "automail".
/RP password
: Specifies the password for the "automail" user account.
Other available parameters to customize a scheduled task programmatically include:
/sd
: Specifies the start date for the task.
/ed
: Specifies the end date for the task.
/ri
: Specifies the repetition interval in minutes for the task.
/du
: Specifies the duration for which the task should repeat, in the format HH:mm.
/k
: Indicates that the task should stop when the repetition duration is reached.
/it
: Allows the task to run interactively only if the user is logged on.
/np
: Disables printing of the scheduler status messages.
/z
: Marks the task for deletion after it runs.
/f
: Forces the task to be created, even if the specified task name already exists.
/xml
: Specifies the XML file containing the task definition.
For a complete list of parameters, refer to the official Microsoft documentation.