Multi-process management tool: Goreman

Source: Internet
Author: User
Tags etcd
This is a creation in Article, where the information may have evolved or changed.

Linux under the multi-process management tools for development and operations are very useful, common features of the main mainstream tools are Monit, supervisor. However, it is recommended to use the lightweight gadget goreman in development.

Goreman is a rewrite of the widely used foreman under Ruby, after all, Golang-based tools are much easier to use. Incidentally: Goreman's author is Mattn, a Japanese programmer who is active in the Golang community. Foreman original author also implemented a Golang version: Forego, but no goreman good, for example: CoreOS is the ETCD to use the Goreman to start a single-click version of the ETCD cluster.

Installation

The Go tool is easy to install:

go get github.com/mattn/goremangoreman help

Of course, remember to configure Gopath, Goroot environment variables, and remember to add $gopath/bin to $path

Use

Because it is a gadget, reference Goreman Help is basic enough. Simple Steps to use:

    1. Create a new Procfile file that needs to be goreman-f specified if it is renamed.

    2. Execute under directory containing procfile: Goreman start

    3. When off, the ctrl-c is launched directly, Goreman will automatically shut all the processes that are started

Example

As an example of the use of Apache Kafka, a friend should know that Kafka usually needs to start two processes when used: A zookeeper, a Kafka broker, so you can write Kafka for a Procfile development environment:

zookeeper: bash ~/tool/kafka_2.11-0.8.2.1/bin/zookeeper-server-start.sh config/zookeeper.propertiesbroker: bash ~/tool/kafka_2.11-0.8.2.1/bin/kafka-server-start.sh config/server.properties

Then execute Goreman start, you can see the different color-differentiated zookeeper, Kafka broker process startup log:

11:04:10 zookeeper | Starting zookeeper on port 500011:04:10    broker | Starting broker on port 5001...

When turned off, the two bash processes are automatically closed when ctrl-c directly.

Advanced usage

This is the simplest use scenario: use Goreman start directly, but there is a disadvantage that Goreman binds to the current session and cannot flexibly control the start and stop of multiple processes and the order. In the actual development process, it is often necessary to start and stop a process related to a module that is being developed, such as the kafka-broker in the example above, and zookeeper usually does not require frequent start-stop.

You can use the more advanced Goreman Run command, such as:

# 先启动Zookeepergoreman run start zookeeper# 然后启动kafkagoreman run start broker# 查看进程状态goreman run status# 停止broker进程goreman run stop broker# 重启broker进程goreman run restart broker

Summarize

Multi-process management is the most commonly used tool in the development of Internet web and server backend, especially after the cloud, the MicroServices micro-service architecture, which is widely admired by cloud application, increases the number of back-end processes. Goreman is ideal for use in development environments, with the ability to manage multiple background processes in one click and to clean up the environment in a timely manner. However, the real production environment, or the use of monit/m, supervisor and other more mature and stable, full-featured multi-process management tools.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.