refactor(daemon): systemd oneshot+timer → 常駐デーモン方式へ変更 (issue #54)#55
Merged
liplus-lin-lay merged 1 commit intomainfrom Mar 5, 2026
Merged
refactor(daemon): systemd oneshot+timer → 常駐デーモン方式へ変更 (issue #54)#55liplus-lin-lay merged 1 commit intomainfrom
liplus-lin-lay merged 1 commit intomainfrom
Conversation
## 設計判断 systemd タイマー方式では DDNS_TIME と UPDATE_TIME の 2 軸を 1 本のタイマーで 管理せざるを得ず、任意の組み合わせが正しく動作しない仕様バグがあった。 2 本タイマー案(#53)は systemd 側に複雑さを押し出すだけで、実機デバッグで 「どちらのタイマーのせいか」の切り分けが困難になるため採用しない。 常駐デーモンに変更し、2 本の goroutine ticker で 2 つの間隔を内部管理する。 これにより DDNS_TIME=1d + UPDATE_TIME=2m など任意の組み合わせが正しく動く。 ## 変更内容 - internal/mode/daemon.go: Daemon() 実装 - checkTicker (DDNS_TIME): update → check → err_mail サイクル - keepaliveTicker (UPDATE_TIME): 全 MyDNS エントリ強制更新 - nil channel イディオムで UPDATE_TIME=0 時の keepalive を無効化 - SIGTERM/SIGINT でクリーンシャットダウン - internal/mode/keepalive.go: MyDNS 強制更新コマンド (手動実行用にも残す) - internal/mode/update.go: forceSync / gate ロジックをすべて除去 - cmd/dipper_ai/main.go: daemon / keepalive サブコマンド追加 - systemd/dipper_ai.service: Type=oneshot → Type=simple、Restart=on-failure - systemd/dipper_ai.timer: 削除 - scripts/install.sh: タイマー動的生成ロジックを除去、旧ユニット自動削除追加 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
設計判断(issue #54 より)
問題
DDNS_TIME(チェック間隔)とUPDATE_TIME(keepalive 間隔)が 1 本の systemd タイマーに依存決定: 常駐デーモンに変更
journalctl -u dipper_aiだけで全状態確認DDNS_TIME=1d, UPDATE_TIME=2mなど任意の組み合わせが正しく動くinstall.shからタイマー動的生成ロジックが消えてシンプルになった変更ファイル
internal/mode/daemon.go新規internal/mode/keepalive.go新規(手動実行用にも残す)internal/mode/update.goforceSync / gate ロジック除去cmd/dipper_ai/main.godaemon / keepalive コマンド追加systemd/dipper_ai.serviceType=simple、Restart=on-failuresystemd/dipper_ai.timer削除scripts/install.sh大幅シンプル化(旧ユニット自動削除も追加)Closes #54