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