diff --git a/.gitignore b/.gitignore index ea6b25d..67e7f35 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ go.work data/ +dist/ venv/ .env .env.example diff --git a/update.sh b/update.sh index e082ed1..71f0f04 100755 --- a/update.sh +++ b/update.sh @@ -1,22 +1,25 @@ #!/bin/bash +host="root@main" # 更新 go mod, 然後靜態編譯 go mod tidy -go build -o data/main bin/main.go +go build -o dist/main bin/main.go # 上传到服务器, 然後刪除本地文件 -scp ./data/main root@47.103.40.152:~/main_new -rm ./data/main +scp dist/main $host:~/webp/main +rm -rf dist + +# pm2 start /root/webp/main --name webp --watch # 查看 main_ 的進程, 然後使用 kill -9 强制关闭 -ssh root@47.103.40.152 "ps -ef | grep -v grep | grep ./main" -ssh root@47.103.40.152 "kill -9 \`ps -ef | grep -v grep | grep ./main | awk '{print \$2}'\`" +# ssh $host "ps -ef | grep -v grep | grep ./main" +# ssh $host "kill -9 \`ps -ef | grep -v grep | grep ./main | awk '{print \$2}'\`" # 重启服务, 保持服务不被关闭 (pkill ./main; 無效, 還需防止 nohup 不退出) -ssh root@47.103.40.152 "rm ./main; mv ./main_new ./main;" -ssh root@47.103.40.152 "nohup ./main test >> nohup.out 2>&1 &" -ssh root@47.103.40.152 "nohup ./main server >> nohup.out 2>&1 &" -ssh root@47.103.40.152 "ps -ef | grep -v grep | grep ./main" +#ssh $host "rm ./main; mv ./main_new ./main;" +#ssh $host "nohup ./main test >> nohup.out 2>&1 &" +#ssh $host "nohup ./main server >> nohup.out 2>&1 &" +#ssh $host "ps -ef | grep -v grep | grep ./main" # 查看日志 # ssh root@47.103.40.152 "tail -fn 50 nohup.out"