分布式学习(2)etcd@1@goreman

一、什么是goreman

goreman是一个go语言编写的多进程管理工具,是对Ruby下广泛使用的foreman的重写(foreman原作者也实现了一个golang版:forego,不过没有goreman好用)相比较monit、supervisor而言要简单的多,而且可以在项目级别管理进程,比较适合开发环境使用。比如快速运行和一项目相关的所有进程,goreman就可以派上用场。coreos的etcd就是使用的goreman来一键启停单机版的etcd集群。

二、安装

cd ~/go/src
mkdir -p golang.org/x
cd golang.org/x
git clone https://github.com/golang/sys.git

cd $GOPATH/src
mkdir gopkg.in
cd gopkg.in
git clone https://github.com/go-yaml/yaml.git
mv yaml yaml.v2
cd yaml.v2
go install

cd $GOPATH/src
git clone https://gitee.com/szysyyxtl/goreman.git

cd goreman
go build
./goreman help

#添加环境变量
临时设置

export PATH=/root/go/src/goreman/:$PATH

当前用户的全局设置

vim ~/.profile,添加行: 
export PATH=/root/go/src/goreman/:$PATH 
使生效 
source .profile

所有用户的全局设置

vim /etc/profile 
在里面加入: 
export PATH=/root/go/src/goreman/:$PATH 
使生效 
source /etc/profile

三、使用案例

goreman -f string
string 是文件名即:proc file (default "Procfile")
#如果你创建的名字是Procfile,那么直接 >> goreman start
#如果你创建的名字不是Procfile,那么输入>> goreman -f filename start

传入参数:

我可以携带多个参数来运行,比如Procfile文件为:

hello1: ./helloworld --name=$NAME --age=$AGE
hello2: ./helloworld
hello3: ./helloworld

运行命令为

NAME=Song AGE=18 goreman start

运行单个命令

goreman start hello1

进程控制

当我们通过goreman start命令启动了一组相关的进程后,我们可以在另外的shell中,进入到相同的目录,执行一些进程控制的命令:

goreman run start hello 启动指定的命令
goreman run stop hello 停止指定的进程
goreman run restart hello 重启指定的进程
goreman run restart-all 重启所有进程
goreman run status 查看进程列表和状态,其中前面带*号的标示正在运行中
goreman run list 查看命令名称列表
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值