Skip to content

Commit

Permalink
consistent user experience/systemd start and stop
Browse files Browse the repository at this point in the history
Prior to this commit, if a psd threw an error code starting from psd.service,
psd.service would show up in systemctl as active and psd-resync.service would
show the error and the timer would run. Unless a more simplistic strategy to
interface with systemd can be designed, this is an alternative to give a
consistent experience with systemd.
  • Loading branch information
graysky2 committed Apr 25, 2020
1 parent 349d21a commit 7f253fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions common/profile-sync-daemon.in
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,17 @@ case "$1" in
header
cleanup
;;
startup)
# target for psd.service's ExecStart= for consistent error handling
if [[ ! -f $PID_FILE ]]; then
dep_check
config_check
dup_check
running_check
ungraceful_state_check
echo -e "${BLD}psd startup check successful${NRM}"
fi
;;
sync|resync)
if [[ -f $PID_FILE ]]; then
do_sync
Expand Down
2 changes: 1 addition & 1 deletion init/psd-resync.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Description=Timed resync
After=psd.service
Wants=psd-resync.timer
PartOf=psd.service
BindsTo=psd.service

[Service]
Type=oneshot
Expand Down
2 changes: 1 addition & 1 deletion init/psd-resync.timer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=Timer for profile-sync-daemon - 1Hour
PartOf=psd-resync.service psd.service
BindsTo=psd.service

[Timer]
OnUnitActiveSec=1h
2 changes: 1 addition & 1 deletion init/psd.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ After=winbindd.service
[Service]
Type=oneshot
RemainAfterExit=yes
# psd-resync.service will do the (re)sync due to Wants=psd-resync.service
ExecStart=/usr/bin/profile-sync-daemon startup
ExecStop=/usr/bin/profile-sync-daemon unsync

[Install]
Expand Down

0 comments on commit 7f253fa

Please sign in to comment.