Closed ErnWong closed 4 months ago
Right, seems to be intentional that it returns a non-zero exit code unless it is manually unmounted using fusermount
as we were trying to with our ExecStop
step: https://forum.rclone.org/t/non-zero-exit-status-from-rclone-mount-even-with-clean-unmount/38884
I wonder if it's because I tried using the fusermount binary from the nixpkg directly, rather than from the installed folder which would have the setuid flags and stuff? https://discourse.nixos.org/t/fusermount-systemd-service-in-home-manager/5157/3
And that seems to have fixed the failures:
May 11 22:54:55 kaiki systemd[2696]: Starting Mount Google Drive...
░░ Subject: A start job for unit UNIT has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit UNIT has begun execution.
░░
░░ The job identifier is 1439.
May 11 22:54:56 kaiki systemd[2696]: Started Mount Google Drive.
░░ Subject: A start job for unit UNIT has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit UNIT has finished successfully.
░░
░░ The job identifier is 1439.
May 11 22:55:00 kaiki systemd[2696]: Stopping Mount Google Drive...
░░ Subject: A stop job for unit UNIT has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A stop job for unit UNIT has begun execution.
░░
░░ The job identifier is 1452.
May 11 22:55:00 kaiki systemd[2696]: Stopped Mount Google Drive.
░░ Subject: A stop job for unit UNIT has finished
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A stop job for unit UNIT has finished.
░░
░░ The job identifier is 1452 and the job result is done.
Now let's see if this allows the service to automatically start after reboot.
Hmmm, unfortunately even though https://github.com/ErnWong/dotfiles/commit/7ff90c6f612001e04f54c792e94ee9b22ca848d9 helped remove the failures when stopping the service, it did not make the service automatically start up.
Perhaps it's because multi-user.target is a system level target but we are trying to set up a user level target? https://unix.stackexchange.com/questions/698463/service-in-systemd-user-mode-inactive-dead
I see home manager examples use default.target as well, so maybe I should give that a try.
And this seems to be it. Nixos rebuild now starts up the service it looks like!
~/dotfiles> sudo nixos-rebuild switch --flake .#kaiki 05/11/2024 11:02:30 PM
[sudo] password for ernwong:
warning: Git tree '/home/ernwong/dotfiles' is dirty
building the system configuration...
warning: Git tree '/home/ernwong/dotfiles' is dirty
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
reloading user units for ernwong...
restarting sysinit-reactivation.target
restarting the following units: home-manager-ernwong.service
the following new units were started: home-ernwong-gdrive.mount, sysinit-reactivation.target, systemd-tmpfiles-resetup.service
Status after reboot is:
But I can always manually start it up with
Things I've tried:
Changing the startServices option to true ("legacy"), commenting startServices out. No luck.
Perhaps it's because it's failing in some way when it is being shutdown, and this failure makes systemd not try to re-start it the next time? Not sure.
I've also tried commenting out the failing
ExecStop
script as unmounting was failing:however we still get a failure when stopping the service even without that
ExecStop
step: