From cef0675a8801e480d709372891c1c04b27f399be Mon Sep 17 00:00:00 2001 From: syui Date: Sat, 14 Jun 2025 00:50:22 +0900 Subject: [PATCH] add system --- README.md | 35 ++++++++++++++++++++++++++ systemd/system/ailog-stream.service | 22 ++++++++++++++++ systemd/system/cloudflared-log.service | 25 ++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 systemd/system/ailog-stream.service create mode 100644 systemd/system/cloudflared-log.service diff --git a/README.md b/README.md index 2586d89..0903ed4 100644 --- a/README.md +++ b/README.md @@ -603,6 +603,41 @@ translation = true - Check AI provider configuration - Ensure sufficient context in memory system +## systemd + +```sh +# ファイルをsystemdディレクトリにコピー +sudo cp ./systemd/system/ailog-stream.service /etc/systemd/system/ +sudo cp ./systemd/system/cloudflared-log.service /etc/systemd/system/ + +# 権限設定 +sudo chmod 644 /etc/systemd/system/ailog-stream.service +sudo chmod 644 /etc/systemd/system/cloudflared-log.service + +# systemd設定reload +sudo systemctl daemon-reload + +# サービス有効化・開始 +sudo systemctl enable ailog-stream.service +sudo systemctl enable cloudflared-log.service + +sudo systemctl start ailog-stream.service +sudo systemctl start cloudflared-log.service + +# 状態確認 +sudo systemctl status ailog-stream.service +sudo systemctl status cloudflared-log.service + +# ログ確認 +journalctl -u ailog-stream.service -f +journalctl -u cloudflared-log.service -f + +設定のポイント: +- User=syui でユーザー権限で実行 +- Restart=always で異常終了時自動再起動 +- After=network.target でネットワーク起動後に実行 +- StandardOutput=journal でログをjournalctlで確認可能 +``` ## License diff --git a/systemd/system/ailog-stream.service b/systemd/system/ailog-stream.service new file mode 100644 index 0000000..4e2a1ea --- /dev/null +++ b/systemd/system/ailog-stream.service @@ -0,0 +1,22 @@ +[Unit] +Description=ailog stream monitoring service +After=network.target +Wants=network.target + +[Service] +Type=simple +User=syui +Group=syui +WorkingDirectory=/home/syui/git/log +ExecStart=/home/syui/.cargo/bin/ailog stream start my-blog +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +# Environment variables if needed +Environment=RUST_LOG=info +Environment=AILOG_DEBUG_ALL=1 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/systemd/system/cloudflared-log.service b/systemd/system/cloudflared-log.service new file mode 100644 index 0000000..7f65540 --- /dev/null +++ b/systemd/system/cloudflared-log.service @@ -0,0 +1,25 @@ +[Unit] +Description=Cloudflared tunnel for log.syui.ai +After=network.target +Wants=network.target + +[Service] +Type=simple +User=syui +Group=syui +WorkingDirectory=/home/syui/git/log +ExecStart=/usr/bin/cloudflared tunnel --config /home/syui/git/log/cloudflared-config.yml run +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +# Security hardening +NoNewPrivileges=true +ProtectSystem=strict +ProtectHome=read-only +ReadWritePaths=/home/syui/git/log +PrivateTmp=true + +[Install] +WantedBy=multi-user.target \ No newline at end of file