From ef8fac7ec2a6a34dcca4cccec6a9f01d5f211817 Mon Sep 17 00:00:00 2001 From: Milky0217 Date: Wed, 25 Mar 2026 17:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0systemd=20service=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=9B=B4=E6=96=B0=E9=83=A8=E7=BD=B2=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- deploy.sh | 2 +- rust-backend.service | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 rust-backend.service diff --git a/deploy.sh b/deploy.sh index 34e0a2d..9309e0f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -126,4 +126,4 @@ main() { } # 执行主函数 -main \ No newline at end of file +main diff --git a/rust-backend.service b/rust-backend.service new file mode 100644 index 0000000..a4479ce --- /dev/null +++ b/rust-backend.service @@ -0,0 +1,31 @@ +[Unit] +Description=Rust Backend Service (Weather Data Collection API) +After=network.target postgresql.service +Wants=network.target + +[Service] +Type=simple +User=root +Group=root +WorkingDirectory=/root/rust/rust_backend +ExecStart=/root/rust/rust_backend/rust-backend +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +# 环境变量配置 +EnvironmentFile=/root/rust/rust_backend/.env + +# 安全加固 +NoNewPrivileges=yes +PrivateTmp=yes +ProtectSystem=strict +ProtectHome=read-only +ReadWritePaths=/root/rust/rust_backend + +# 日志标识 +SyslogIdentifier=rust-backend + +[Install] +WantedBy=multi-user.target \ No newline at end of file