beego在项目有修改时可以用热更新来完成代码更新,达到项目不间断完成升级
1:修改beego配置文件 Graceful = true
2:更新代码到服务器 git push
3:查找服务id ps -aux|grep admin //admin是我的项目名称
root 26070 0.2 0.6 299788 7112 pts/2 Sl 18:33 0:01 ./admin
root 26152 0.0 0.8 301196 8856 pts/2 Sl 18:34 0:00 ./admin -graceful
root 26434 0.1 0.8 299788 8540 pts/2 Sl 18:37 0:00 ./admin -graceful
root 26499 0.4 1.0 299788 10516 pts/2 Sl 18:38 0:01 ./admin -graceful
root 26803 0.4 1.2 439056 12864 pts/2 Sl 18:43 0:00 admin
root 26825 0.0 0.0 112704 976 pts/1 S+ 18:43 0:00 grep --color=auto admin
4:执行 kill -HUP 26803
此时如果是bee run 下运行的可以看到已经更新服务了
2020/06/04 18:34:11 26070 Received SIGHUP. forking.
2020/06/04 18:34:11 [0xc000509c68]
2020/06/04 18:34:11 laddr :8060 ptr offset 0
2020/06/04 18:34:11 26152 :8060
2020/06/04 18:34:11 26070 Received SIGTERM.
2020/06/04 18:34:11 26070 Waiting for connections to finish...
2020/06/04 18:34:11 26070 [::]:8060 Listener closed.
2020/06/04 18:35:05 26070 Received SIGHUP. forking.
admin/controllers
admin/routers
admin
2020/06/04 18:36:57 SUCCESS ▶ 0006 Built Successfully!