使用foreman 管理基于Procfile 的应用

foreman 是一个协议,我们可以用来方便的管理基于Procfile 文件定义的应用(测试环境会很方便,当然生产也可以使用)
我们可以用来快速的搭建一个服务的依赖系统,同时方便的进行管理,同时社区也有了多种语言的实现

几个方便的语言实现

一个基于goreman 部署的本地etcd 集群

  • Procfile
 
# Use goreman to run `go get github.com/mattn/goreman`
# Change the path of bin/etcd if etcd is located elsewhere
etcd1: bin/etcd --name infra1 --listen-client-urls http://${IP}:2379 --advertise-client-urls http://${IP}:2379 --listen-peer-urls http://${IP}:12380 --initial-advertise-peer-urls http://${IP}:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster ‘infra1=http://${IP}:12380,infra2=http://${IP}:22380,infra3=http://${IP}:32380‘ --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
etcd2: bin/etcd --name infra2 --listen-client-urls http://${IP}:22379 --advertise-client-urls http://${IP}:22379 --listen-peer-urls http://${IP}:22380 --initial-advertise-peer-urls http://${IP}:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster ‘infra1=http://${IP}:12380,infra2=http://${IP}:22380,infra3=http://${IP}:32380‘ --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
etcd3: bin/etcd --name infra3 --listen-client-urls http://${IP}:32379 --advertise-client-urls http://${IP}:32379 --listen-peer-urls http://${IP}:32380 --initial-advertise-peer-urls http://${IP}:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster ‘infra1=http://${IP}:12380,infra2=http://${IP}:22380,infra3=http://${IP}:32380‘ --initial-cluster-state new --enable-pprof --logger=zap --log-outputs=stderr
proxy: bin/etcd grpc-proxy start --endpoints=${IP}:2379,${IP}:22379,${IP}:32379 --listen-addr=${IP}:23790 --advertise-client-url=${IP}:23790 --enable-pprof
?
# A learner node can be started using Procfile.learner
?
  • 环境变量
    .env 文件
 
IP=127.0.0.1
  • 启动
goreman -f Procfile start

参考资料

https://ddollar.github.io/foreman/
https://github.com/mattn/goreman

相关推荐