17个版本

0.3.2 2019年2月25日
0.3.1 2018年9月12日
0.2.6 2018年9月9日
0.2.4 2018年8月27日
0.1.6 2018年8月16日

#755Unix API

每月 46次下载

MIT/Apache

145KB
4K SLoC

Firestarter:进程和共享套接字管理器

crates.io Patreon

Firestarter是一个简单易用的进程和共享套接字管理器,其设计灵感来源于circuseinhorn,它以轻量级和快速著称。

Firestarter可以像circus一样管理进程和共享套接字组。并且像einhorn一样,我们支持手动确认。您还可以通过Ctrl命令控制Firestarter守护进程,例如增加工作进程。

Firestarter使用systemd socket passing protocol(LISTEN_FDS)共享套接字。

Firestarter使用显式配置文件而不是复杂的命令行选项。

特性

  • 易于安装
  • 快速且节省内存
  • 使用显式配置文件
  • 支持类似circus的控制命令
  • 支持类似einhorn的确认机制
  • 执行升级程序

安装

您可以通过使用cargo安装来获取firestarter

$ cargo install firestarter

使用方法

Firestarter是进程和共享套接字管理器。运行firestarter -h以查看详细使用方法。

firestarter
process and shared socket manager

USAGE:
    firestarter <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    ctrl      Run control client
    help      Prints this message or the help of the given subcommand(s)
    list      Show worker names
    run       Run daemon
    status    Show worker status
    stop      Stop daemon

示例

$ firestarter run --config misc/config.toml

配置文件使用toml格式。以下是一个示例。

[worker1] # set worker group name.

# set to commands with their arguments that are executed when this worker is started.
# exec_start = "./demo/target/debug/demo"
exec_start = "/usr/bin/emacs --fg-daemon"

# set to commands to execute to stop the service started via exec_start.
# if you do not set it, sigterm will be sent to the exec_start process.
# note that upgrade ack does not use this command.
exec_stop = "/usr/bin/emacsclient --eval (kill-emacs)"

# set the number of startup processes.
numprocesses = 1

# set working directory.
# working_directory = "/tmp".

# set restart policy. default is none.
# none: not restart process.
# on-failure: restart the process if it is not completed normally.
# always: restart the process whenever you exit.
restart = "on-failure"

# set the seconds to delay the startup of the process.
# warmup_delay = 1

# start the process immediately without starting the process when connecting the client socket.
start_immediate = true

# set shared socket addresses.
# it also support unix domain socket. (e.g.: /tmp/foo.sock)
socket_address = ["127.0.0.1:4000", "127.0.0.1:4001"]

# set processes environment.
environments=["TEST_A=XXXX", "TEST_B=YYYY"]

# set upgrade ack type. this is similar to einhorn 's ACKs. timer is default.
# timer: it will terminate the old process after a certain time (sec).
# manual: send ack manually. For details, refer to einhorn's manual ack document
# none: no ack. simple stop and start
ack = "manual"

# set timer ack time in seconds. default 1sec.
# ack_timeout = 1

# set ack signal. default is SIGUSR2.
# ack_signal = "SIGUSR2"

# set uid.
# uid = 1000

# set gid.
# gid = 10

# set stdout to file.
# size and timed rotate supported.
# the format is below.
# size:<max file size>:<number of backup>:<output path>
# time:<rollover interval>:<type of interval>:<timzone for rotate>:<number of backup>:<output path>
# the type of timezeone for rotate,the list of possible values is below.
#‘U’UTC
#‘L’Local
# the type of interval,the list of possible values is below.
#‘S’Seconds
#‘M’Minutes
#‘H’Hours
#‘D’Days
#
# exmple
# stdout_log = "size:10240:5:/tmp/web1_out.log"
# it rolls over in 3 days and keeps 5 backups.
# stdout_log = "time:3:D:U:7:/tmp/web1_out.log"

# set stderr to file.
# it is the same as stdout.
# stderr_log = "size:10240:5:/tmp/web1_err.log"

# set process live check configuration.
# we will check the existence of the process (experimental).
# the process needs to periodically update the mtime of the file passed in environment variable FIRESTARTER_WATCH_FILE.
# the monitoring process kills the process when the mtime update interval exceeds the threshold. this is the same process as gunicorn's worker notify.
# the unit is seconds, and the default value is 0. (disable live check)
# live_check_timeout = 60

# set auto upgrade.
# it will send upgrade command when their command file is modified.
# it does the same processing as circus.plugins.CommandReloader.
# auto_upgrade = false

# set upgrader program.
# set to the upgrader command.
# run upgrade only when the upgrader command terminates normally.
# upgrader = "/a/b/upgrader --config abc"

# set upgrade timing.
# execute the upgrader command for each specified seconds.
# if not set, execute the upgrade command when executing the upgrade ctrl command.
# upgrader_active_sec=10
# upgrader_timeout=60

...


控制命令

Firestarter还提供了一个用于控制运行守护进程的客户端。

例如,您可以使用以下命令检查状态。

$ firestarter ctrl worker1 status
send ctrl command [status] to [worker1] worker
[worker1] active
processes [24170]
time 00:00:06

有关详细信息,请参阅帮助信息firestarter ctrl -h

贡献

欢迎贡献!请将PR推送到dev分支。

依赖项

~8–19MB
~238K SLoC