update
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=gin-article Application
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=ubuntu
|
||||
WorkingDirectory=APP_PATH
|
||||
ExecStart=APP_PATH/app >> APP_PATH/app.log 2>&1
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 获取当前目录的绝对路径
|
||||
app_path=$(cd "$(dirname "$0")"; pwd)
|
||||
|
||||
# 执行 git pull 命令
|
||||
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 /etc/systemd/system
|
||||
|
||||
# 重新加载 systemd 配置文件
|
||||
systemctl daemon-reload
|
||||
|
||||
# 启动应用程序服务
|
||||
systemctl restart app.service
|
||||
Reference in New Issue
Block a user