So, I had this old line in inittab:
Gar:2345:respawn:start-stop-daemon --start -p /tmp/garage.pid -m --exec /usr/bin/java -v -d /home/pi/builds -- -jar garageController.jar
And now I want to run it on a new Raspberry Pi.
So, we need to create a service, its actually quite simple. I created the file /etc/systemd/system/garage.service with this text:
[Unit]
Description=Garage Door Control Software
[Service]
Type=simple
PIDFile=/var/tmp/garage.pid
ExecStart=/usr/bin/java -jar garageDoor.jar gpio
#ExecStart=/home/pi/builds/start_controller.sh
WorkingDirectory=/home/pi/builds
Restart=always
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable garage.service
sudo systemctl start garage.service
sudo systemctl --all | grep garage
##this should show that the service is started.
That's it.
(I used instructions from https://n3mesisfixx.blogspot.ie/2012/08/migrate-etcinittab-job-to-systemd-in.html)
1 comment:
Helpful guide. great job!
Post a Comment