diff --git a/app.service b/app.service.example similarity index 100% rename from app.service rename to app.service.example diff --git a/build.sh b/build.sh index 78d8d33..46c0c9b 100644 --- a/build.sh +++ b/build.sh @@ -11,10 +11,12 @@ cd ${app_path} && git pull # 执行 go build 命令 cd ${app_path} && go build -o app -# 替换 app.service 文件中的 APP_PATH -sed -i "s|APP_PATH|${app_path}|g" app.service +cp app.service.example ${app_name}.service -cp app.service /etc/systemd/system/${app_name}.service +# 替换 app.service 文件中的 APP_PATH +sed -i "s|APP_PATH|${app_path}|g" ${app_name}.service + +mv ${app_name}.service /etc/systemd/system/${app_name}.service # 重新加载 systemd 配置文件 systemctl daemon-reload