Re: [Tutor] systemd
> On Mar 3, 2019, at 08:46, Dave Hill wrote: > > > I would like to take advantage of the 'restart' functionality, but I still > wish to have a method of exiting > > i.e. Restart=always > > Is there a way in which I can have automatic restart but also have a way of > exiting? > Maybe “always” is not what you want. If you use “on-failure" instead, it will restart in all cases except when it cleanly exits. From systemd.service manpage: https://manpages.debian.org/jessie/systemd/systemd.service.5.en.html "Setting this to on-failure is the recommended choice for long-running services, in order to increase reliability by attempting automatic recovery from errors. For services that shall be able to terminate on their own choice (and avoid immediate restarting), on-abnormal is an alternative choice.” You will also see a table of what each setting does, to help you pick the best option for your needs. You might also want to set the RestartSec to something other than zero. If you set it to something like 20 seconds, it would also give you time to manually disable the service if you needed to. — David Rock da...@graniteweb.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] systemd
> On Mar 3, 2019, at 14:59, Cameron Simpson wrote: > > On 03Mar2019 16:01, Alan Gauld wrote: >> On 03/03/2019 14:46, Dave Hill wrote: >>>python3 /home/pi/Code/TestVideo#6.py CLIP0026.MP4 20 DEBUG >> >> To be honest I'm surprised that works. >> I'd expected bash to interpret the # as a comment delimiter! >> But I tried it and it seems ok, you live and learn... > > The octothorpe is only a comment marker at the start of a word. While it works, it’s usually a bad idea to use non alphanumeric characters for filenames. Naming it TestVideo6.py would be less prone to “weird things” happening down the road. — David Rock da...@graniteweb.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] systemd
On 03Mar2019 16:01, Alan Gauld wrote: On 03/03/2019 14:46, Dave Hill wrote: python3 /home/pi/Code/TestVideo#6.py CLIP0026.MP4 20 DEBUG To be honest I'm surprised that works. I'd expected bash to interpret the # as a comment delimiter! But I tried it and it seems ok, you live and learn... The octothorpe is only a comment marker at the start of a word. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] systemd
Thank you - registering with Linux Mint On 03/03/2019 16:01, Alan Gauld via Tutor wrote: On 03/03/2019 14:46, Dave Hill wrote: on power up, and I thought that I would use 'systemd'. This is really a Linux question not Python so you might like to try the Mint forums too. They are usually pretty responsive. [Service] Type=idle User=pi ExecStart=/bin/bash /home/pi/Code/testVideo.sh Restart=no RestartSec=0 where 'testVideo.sh' ## Dave Hill, 28/02/2019 # 2 = HDMI, 1 = headphones, 0 = Auto amixer cset numid=3 1 python3 /home/pi/Code/TestVideo#6.py CLIP0026.MP4 20 DEBUG To be honest I'm surprised that works. I'd expected bash to interpret the # as a comment delimiter! But I tried it and it seems ok, you live and learn... Is there a way in which I can have automatic restart but also have a way of exiting? That's the Linux bit... :-) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] systemd
On 03/03/2019 14:46, Dave Hill wrote: > on power up, and I thought that I would use 'systemd'. This is really a Linux question not Python so you might like to try the Mint forums too. They are usually pretty responsive. > [Service] > Type=idle > > User=pi > ExecStart=/bin/bash /home/pi/Code/testVideo.sh > > Restart=no > RestartSec=0 > where 'testVideo.sh' > > ## Dave Hill, 28/02/2019 > > # 2 = HDMI, 1 = headphones, 0 = Auto > amixer cset numid=3 1 > > python3 /home/pi/Code/TestVideo#6.py CLIP0026.MP4 20 DEBUG To be honest I'm surprised that works. I'd expected bash to interpret the # as a comment delimiter! But I tried it and it seems ok, you live and learn... > Is there a way in which I can have automatic restart but also have a way > of exiting? That's the Linux bit... :-) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] systemd
Hi, I am nearly ready for the new season on the Heritage railway I volunteer on and I am putting the final touches to a revamped 'runaway train' attraction in the museum. The last act is to get the code to auto-start on power up, and I thought that I would use 'systemd'. The code runs on a Raspberry Pi; via the GPIO: sensing an input, reed switch, and controlling three outputs; smoke machine, fan and vibrating floor. on activation a video is played, at 8 times real speed, which is viewed through a mock-up of a loco cab. I can run a program using: [Unit] Description=TestVideo Service After=multi-user.target [Service] Type=idle User=pi ExecStart=/bin/bash /home/pi/Code/testVideo.sh Restart=no RestartSec=0 [Install] WantedBy=multi-user.target where 'testVideo.sh' ## Dave Hill, 28/02/2019 # 2 = HDMI, 1 = headphones, 0 = Auto amixer cset numid=3 1 python3 /home/pi/Code/TestVideo#6.py CLIP0026.MP4 20 DEBUG exit 0 as I want to control the audio output, in this case direct audio to the Raspberry Pi stereo output. The program runs an infinite loop that can be exited by Cntrl-C I would like to take advantage of the 'restart' functionality, but I still wish to have a method of exiting i.e. Restart=always Is there a way in which I can have automatic restart but also have a way of exiting? Thanks in advance, Dave ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor