Golang笔记

einhorn 与 goji 热部署

优秀go web 框架支持热部署,需要einhorn 支持。下面是一些经验:

einhorn 安装

sudo aptitude install libgemplugin-ruby
sudo gem install einhorn

einhorn 与 goji 热部署

开启进程

$ einhorn -b 127.0.0.1:9000 -m manual -c golangnote /path/golangnote
$ nohup einhorn -b 0.0.0.0:8000 -m manual -c golangnote /home/deploy/app/main > /tmp/app.out&

说明:参数-c 是自定义进程名,在后面管理时使用,管理该进程:

$ einhornsh -c golangnote
> upgrade

einhornsh -c golangnote -e upgrade

完成更新

einhornsh 使用文档

> help
You are speaking to the Einhorn command socket. You can run the following commands:

config: Merge in a new set of config options. (Note: this will likely be subsumed by config file reloading at some point.)
dec: Decrement the number of Einhorn child processes
die: Send SIGNAL (default: SIGUSR2) to all workers, stop spawning new ones, and exit once all workers die (args: [SIGNAL])
help: Print out available commands
inc: Increment the number of Einhorn child processes
louder: Increase verbosity
quieter: Decrease verbosity
reload: Reload Einhorn
set_workers: Set the number of Einhorn child processes
signal: Send one or more signals to all workers (args: SIG1 [SIG2 ...])
state: Get a dump of Einhorn's current state
upgrade: Upgrade all Einhorn workers smoothly. This causes Einhorn to reload its own code as well.
upgrade_fleet: Upgrade all Einhorn workers a fleet at a time. This causes Einhorn to reload its own code as well.
> reload
Reloading, as commanded
> upgrade
Upgrading smoothly, as commanded
Starting smooth upgrade from version 0...
===> Launched 9191 (index: 1)
Upgraded successfully to version 1 (Einhorn 0.6.4).
Upgrade done
> 

einhorn 项目地址 https://github.com/stripe/einhorn 32

延伸阅读 https://github.com/zenazn/goji/issues/105 15

本文网址: https://golangnote.com/topic/87.html (转载注明出处)
关于GolangNote:记录在工作中使用golang 遇到、面临的相关问题及解决方法。如果你在这里获得一些知识或信息,解决你的编程问题,请考虑捐赠给不幸的人或者你喜欢的慈善机构,除捐赠外,种植树木、志愿服务或减少排碳的行为也很有益处。如果你有任何问题可以在下面 留言
Be the first to comment!
Captcha image
Relative Articles