Hi @paul.reisinger,
Well, that seems really fun to work on.
And it’s really great to hear your daughter has an interesting passion. That’s awesome!
Regarding the other issue you’ve brought the word about, I think you can easily do it by creating a service and enabling it with systemd
to run on boot.
Here’s what you have to do:
Step 1
Use the following template to write your unit file
- that’s how it’s called.
[Unit]
Description=My application name
[Service]
Type=idle
ExecStart=/usr/bin/python /path/to/my/python/app.py
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
Step 2
Give this filename a name following this template: mywebservice.service
.
Please, keep in mind that the extension must be .service
.
Copy paste the file to /etc/systemd/system/
folder. You’ll need to use sudo
for it.
Step 3
From within the terminal type the following commands:
sudo systemctl daemon-reload
// reloads all the unit files - including our recently added one
sudo systemctl enable mywebservice.service
// enables the service -> it will make the app start on boot
sudo systemctl start mywebservice.service
// enter this command so that you don't have to reboot
// in order for the service to get started
Also, if you wish to disable the service use the sudo systemctl disable myservice.service
.
If you wish to update the systemd
with new changes brought to the unit file
use sudo systemctl daemon-reload
.
And for stopping the service use sudo systemctl stop myservice.service
.
That simple!
Conclusion
Now, whenever the Raspberry Pi
boots up, your program found at /path/to/my/python/app.py
will get launched.
If the app fails to run, or during its operation it stops, it gets restarted after 2 seconds
, no matter what.
If you want to restart the server and bring new changes that you’ve been working on, you can issue the following command:
sudo systemctl restart mywebservice.service
Hope this will get the software up and running for the next week, on hobby day.
Thank you!