优秀go web 框架支持热部署,需要einhorn 支持。下面是一些经验:
einhorn 安装
1
2
sudo aptitude install libgemplugin-ruby
sudo gem install einhorn
einhorn 与 goji 热部署
开启进程
1
2
$ 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
是自定义进程名,在后面管理时使用,管理该进程:
1
2
$ einhornsh -c golangnote
> upgrade
或
1
einhornsh -c golangnote -e upgrade
完成更新
einhornsh 使用文档
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
> 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
- 延伸阅读 Build and Deploy to production
本文网址: https://golangnote.com/topic/87.html 转摘请注明来源