I have a Debian based OS, and I am creating a program that have support for upgrading itself. The program is ran on system-level as a systemd service.
I have a problem when I update the software, which in practice means replacing some files on /opt/myApp/
folder (home of all my application code) and replacing systemd service unit file /etc/systemd/system/my_service.service
. After this I run systemctl daemon-reload
, systemctl enable my_service
and systemctl restart
which works as intended. How ever, if a sudden power loss happens right after this, the new files copied to /opt/myApp/
and the new service file goes to size 0 in the filesystem, which of course then causes my program to fail and the service to go into masked state. If I reboot my system after the installation, the "danger" goes away and the system can handle sudden power losses without effect on the files I care about.
Is this some kind of file system corruption problem? How could I prevent this problem without rebooting the system? What could be the root of this issue?