update.sh 886 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. set -e
  3. # 复制Nginx、服务配置配置
  4. sudo cp -r ./tools/centos/* /
  5. # 复制后端服务到运行目录
  6. sudo rm -rf /data/wwwroot/server
  7. sudo cp -r ./server /data/wwwroot/
  8. # 创建游戏引擎服务端运行目录
  9. if [ ! -d "/data/wwwroot/game" ]; then
  10. mkdir -p /data/wwwroot/game
  11. fi
  12. # shellcheck disable=SC2012
  13. if [ "$(ls -A /data/wwwroot/game/ | wc -l)" -ne 0 ]; then
  14. sudo chmod +x /data/wwwroot/game/*
  15. fi
  16. # 编译后端服务
  17. cd /data/wwwroot/server/
  18. /usr/local/go/bin/go env -w GOSUMDB=off
  19. export GO111MODULE=on && export GOPROXY=https://goproxy.io && /usr/local/go/bin/go build main.go
  20. # 重启Nginx服务
  21. sudo systemctl restart nginx.service
  22. # 重启后端服务和游戏服务
  23. sudo systemctl daemon-reload
  24. sudo systemctl enable server.service
  25. sudo systemctl restart server.service
  26. sudo systemctl enable game.service
  27. sudo systemctl restart game.service