dp-gw 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env sh
  2. # TODO 替换此目录为项目绝对路径
  3. cd /Users/yinbin/workspace/staticweb
  4. git add .
  5. git commit -m 'ok'
  6. git push
  7. ti1=$(date +%s) #获取时间戳
  8. ti2=$(date +%s)
  9. i=$(($ti2 - $ti1 ))
  10. while [[ "$i" -ne "2" ]]
  11. do
  12. ti2=`date +%s`
  13. i=$(($ti2 - $ti1 ))
  14. done
  15. # ""号内为在服务器执行的脚本,请自己修改,支持linux服务器
  16. # 到服务器的项目目录; 更新覆盖代码; 替换host为服务器ip; 安装依赖库; 杀掉之前进程; 开启进程不写入日志
  17. ssh root@bak "cd /root/staticweb;git fetch --all && git reset --hard origin/master && git pull; grep 127.0.0.1:8000 -rl /root/staticweb/ | xargs sed -i 's#127.0.0.1:8000#49.232.53.220:8000#g'; npm i; killall supervisor; nohup supervisor bin/www >/dev/null 2>&1 &"
  18. ti1=$(date +%s) #获取时间戳
  19. ti2=$(date +%s)
  20. i=$(($ti2 - $ti1 ))
  21. while [[ "$i" -ne "3" ]]
  22. do
  23. ti2=`date +%s`
  24. i=$(($ti2 - $ti1 ))
  25. done
  26. echo '大约3秒后热部署完毕,并自动打开浏览器'
  27. # TODO 改为windows命令或者去掉
  28. /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://49.232.53.220:8000/
  29. exit
  30. exit