GolangNote

Golang笔记

einhorn 与 goji 热部署

Permalink

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

einhorn 安装

Bash: einhorn 安装
1
2
sudo aptitude install libgemplugin-ruby
sudo gem install einhorn

einhorn 与 goji 热部署

开启进程

Bash: einhorn 开启进程
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 是自定义进程名,在后面管理时使用,管理该进程:

Bash: einhornsh
1
2
$ einhornsh -c golangnote
> upgrade

Bash: einhornsh upgrade
1
einhornsh -c golangnote -e upgrade

完成更新

einhornsh 使用文档

Bash: 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
> 

本文网址: https://golangnote.com/topic/87.html 转摘请注明来源

Related articles

在自己的网站部署TLS 1.3

前不久Go 1.12 发布,对TLS 1.3 作初步支持,对使用Go 开发的后台来说,这是一个很好的消息。但要启用TLS 1.3 必须添加一个编译参数 `GODEBUG=tls13=1`,等Go 1.13 就默认支持。...

golang web 框架 goji 介绍

goji 是个后起的golang web框架,避免其它golang web 框架走过的坑,在性能、简单性方面做得很好。...

Write a Comment to "einhorn 与 goji 热部署"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 0ms