We were able to use Supervisor to successfully have a Python script run in the background on boot.
Tutorial I Used to set it up: Monitoring Processes with Supervisord
Supervisor runs as a service, and you have a configuration file where you set up your scripts that you want it to run:
[program:your_script_name]
command=python3 your_script_name.py
directory=/your/file/location/here
autostart=true
autorestart=true
You could either have Supervisor run your vending machine scripts on start up or start a script that is waiting for your button press which would then launch your main vending machine script.
Steps: (Using terminal)
sudo apt-get install -y supervisor
Start the service
sudo service supervisor start
Create your configuration information:
sudo nano /etc/supervisor/conf.d/yourscriptname.conf
Enter the configuration information and save the file:
[program:your_script_name]
command=python3 your_script_name.py
directory=/your/file/location/here
autostart=true
autorestart=true
Update Supervisor to include your new configuration file:
supervisorctl reread
supervisorctl update
See if your service started:
supervisorctl
Start and stop the your script from running:
supervisorctl stop your_script_name
supervisorctl start your_script_name