diff --git a/build.sh b/build.sh index 73bb3d3..78d8d33 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,7 @@ #!/bin/bash +app_name=gin-article + # 获取当前目录的绝对路径 app_path=$(cd "$(dirname "$0")"; pwd) @@ -12,10 +14,12 @@ cd ${app_path} && go build -o app # 替换 app.service 文件中的 APP_PATH sed -i "s|APP_PATH|${app_path}|g" app.service -cp app.service /etc/systemd/system +cp app.service /etc/systemd/system/${app_name}.service # 重新加载 systemd 配置文件 systemctl daemon-reload +systemctl stop ${app_name}.service + # 启动应用程序服务 -systemctl restart app.service \ No newline at end of file +systemctl start ${app_name}.service \ No newline at end of file