I am running Raspbian GNU Linux (9) Stretch, on my Raspberry Pi 3.
- Python script which makes use of 2 inputs to the Pi. Calculations are performed based on these inputs, and values are stored in a database.
- A separate Django website which reads values from this database and updates the content of the web page.
Django Server run using:
/home/pi/mysite/manage.py runserver 127.0.0.1:8000
Python Script located at:
On startup I would like to first make sure that my Django server is up and running and then start my python script.
What I have done so far
I came across the following question, but this is not what I am looking for. However most of the information is highly relevant.
if Type=simple in your unit file, you can only specify one ExecStart, but you can add as many ExecStartPre,ExecStartPost`, but none of this is suited for long running commands, because they are executed serially and everything one start is killed before starting the next one.
If Type=oneshot you can specify multiple ExecStart, they run serially not in parallel.
Initially I started by trying to get the python script to run on startup. To do this I am using a simple
systemd service as follows.
[Unit] Description=My script [Service] ExecStart=/usr/bin/python3 /home/pi/Desktop/myscript.py [Install] WantedBy=multi-user.target
This runs without error and initiates the python script on startup.
However, I cannot get my Django server up and running inside the same systemd service since only one
ExecStart is allowed. I need both to be run in parallel.
Any suggestions on how this can be done?-