Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Lennart Poettering
On Mi, 09.08.17 11:28, Tilman Baumann (til...@baumann.name) wrote: > In my experience, the only place where you can hook in a non racy way is > in the kernel. I fully agree with this btw. The only safe place if the kernel does all this. Much like most other drivers UPS drivers should be in the

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Lennart Poettering
On Mi, 09.08.17 11:02, Marek Floriańczyk (marek.florianc...@gmail.com) wrote: > The question is, will my binary be able to open RS232 port eg. /dev/ttyACM0 > when filesystem is Read-Only ? Yes, /dev is unaffected. It's an API VFS, not a real file system, and those won't be remounted r/o. > And

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Marek Floriańczyk
Dnia środa, 9 sierpnia 2017 14:54:25 CEST piszesz: > 2017-08-09 14:51 GMT+02:00 Marek Floriańczyk : > > Dnia środa, 9 sierpnia 2017 11:51:07 CEST Tilman Baumann pisze: > >> On 09.08.2017 11:28, Tilman Baumann wrote: > > NUT looks like quite active based on their

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Michael Biebl
2017-08-09 14:51 GMT+02:00 Marek Floriańczyk : > Dnia środa, 9 sierpnia 2017 11:51:07 CEST Tilman Baumann pisze: >> On 09.08.2017 11:28, Tilman Baumann wrote: > > NUT looks like quite active based on their website. > Microupsd daemon handles also some switches and leds

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Marek Floriańczyk
Dnia środa, 9 sierpnia 2017 11:51:07 CEST Tilman Baumann pisze: > On 09.08.2017 11:28, Tilman Baumann wrote: > > DL;DR > > UPS shutdowns are tricky. Clean file-systems are not the only concern. > > But if you can make assumptions about your storage backend you might be > > able to cut corners

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Marek Floriańczyk
Dnia środa, 9 sierpnia 2017 09:17:44 CEST Mantas Mikulėnas pisze: > /dev is a separate filesystem and is never read-only. right ;) > > Another approach would be to let microupsd exit normally, but then start a > separate microupsd instance (e.g. microupsd-shutdown.service) which > schedules the

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Tilman Baumann
On 09.08.2017 11:28, Tilman Baumann wrote: > DL;DR > UPS shutdowns are tricky. Clean file-systems are not the only concern. > But if you can make assumptions about your storage backend you might be > able to cut corners safely. > > In my experience, the only place where you can hook in a non racy

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Tilman Baumann
DL;DR UPS shutdowns are tricky. Clean file-systems are not the only concern. But if you can make assumptions about your storage backend you might be able to cut corners safely. In my experience, the only place where you can hook in a non racy way is in the kernel.

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Mantas Mikulėnas
/dev is a separate filesystem and is never read-only. Another approach would be to let microupsd exit normally, but then start a separate microupsd instance (e.g. microupsd-shutdown.service) which schedules the UPS poweroff. On Wed, Aug 9, 2017, 12:03 Marek Floriańczyk

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Marek Floriańczyk
Dnia środa, 9 sierpnia 2017 10:29:37 CEST Lennart Poettering pisze: > On Di, 08.08.17 16:03, Marek Floriańczyk (marek.florianc...@gmail.com) wrote: > > Hi all, > > > > I have a small device MicroUPS which helps me to shutdown my system on > > embedded devices, it is controlled by script

Re: [systemd-devel] question about system reboot and shutdown

2017-08-09 Thread Jérémy Rosen
Hi I have no problem with changing some code in microupsd so it behave in certain way. It is handling SIGTERM and other signals if needed. The problem for me is that SIGTERM is send to process during system reboot and system halt - so I need to differentiate between the two. SIGTERM is sent, by

Re: [systemd-devel] question about system reboot and shutdown

2017-08-08 Thread Marek Floriańczyk
Dnia wtorek, 8 sierpnia 2017 19:35:12 CEST Mantas Mikulėnas pisze: > I suggest first porting microupsd itself to a native systemd .service file > (so that it'll have process monitoring and everything). That might even fix > part of the problem. Hi I have no problem with changing some code in

Re: [systemd-devel] question about system reboot and shutdown

2017-08-08 Thread Mantas Mikulėnas
I suggest first porting microupsd itself to a native systemd .service file (so that it'll have process monitoring and everything). That might even fix part of the problem. Normally services are given a certain amount of time to stop after SIGTERM (or whatever KillSignal was set, or whatever

Re: [systemd-devel] question about system reboot and shutdown

2017-08-08 Thread Marek Floriańczyk
Dnia wtorek, 8 sierpnia 2017 21:04:18 CEST Andrei Borzenkov pisze: > 08.08.2017 17:03, Marek Floriańczyk пишет: > > What would be the proper way to distinguish between system is going down > > for reboot and for shutdown ? > > Straightforward way is to make your service WantedBy poweroff.target

Re: [systemd-devel] question about system reboot and shutdown

2017-08-08 Thread Andrei Borzenkov
08.08.2017 17:03, Marek Floriańczyk пишет: > > What would be the proper way to distinguish between system is going down for > reboot and for shutdown ? > Straightforward way is to make your service WantedBy poweroff.target and halt.target. You can then have second service WantedBy