This commit is contained in:
2023-03-10 11:36:35 +08:00
parent 51905fc18d
commit 8a65ef1a53
+6 -2
View File
@@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
app_name=gin-article
# 获取当前目录的绝对路径 # 获取当前目录的绝对路径
app_path=$(cd "$(dirname "$0")"; pwd) app_path=$(cd "$(dirname "$0")"; pwd)
@@ -12,10 +14,12 @@ cd ${app_path} && go build -o app
# 替换 app.service 文件中的 APP_PATH # 替换 app.service 文件中的 APP_PATH
sed -i "s|APP_PATH|${app_path}|g" app.service 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 配置文件 # 重新加载 systemd 配置文件
systemctl daemon-reload systemctl daemon-reload
systemctl stop ${app_name}.service
# 启动应用程序服务 # 启动应用程序服务
systemctl restart app.service systemctl start ${app_name}.service