可以自定义systemd中运行软件的用户,用户组同用户
main
AhFei 2023-06-16 23:32:52 +08:00
parent db77d68560
commit 458eb74c94
1 changed files with 6 additions and 5 deletions

View File

@ -11,7 +11,8 @@ WORKSPACE=${2}
passwd=${3} passwd=${3}
uid=${4} uid=${4}
server_address=${5} server_address=${5}
test_or_not=${6} user_name=${6}
test_or_not=${7}
mkdir -p ${WORKSPACE} mkdir -p ${WORKSPACE}
cd ${WORKSPACE} cd ${WORKSPACE}
@ -31,8 +32,8 @@ Description=ServerStatus-Rust Client
After=network.target After=network.target
[Service] [Service]
User=1000 User=${user_name}
Group=1000 Group=${user_name}
Environment="RUST_BACKTRACE=1" Environment="RUST_BACKTRACE=1"
WorkingDirectory=${WORKSPACE} WorkingDirectory=${WORKSPACE}
# EnvironmentFile=~/myserve/serverstatus/.env # EnvironmentFile=~/myserve/serverstatus/.env
@ -69,8 +70,8 @@ Description=ServerStatus-Rust Server
After=network.target After=network.target
[Service] [Service]
User=1000 User=${user_name}
Group=1000 Group=${user_name}
Environment="RUST_BACKTRACE=1" Environment="RUST_BACKTRACE=1"
WorkingDirectory=${WORKSPACE} WorkingDirectory=${WORKSPACE}
ExecStart=${WORKSPACE}/stat_server -c ${WORKSPACE}/config.toml ExecStart=${WORKSPACE}/stat_server -c ${WORKSPACE}/config.toml