本工具的理念是简单快速管理后台进程。基本是 Procodile 这个项目的移植版,这个项目已经没有再维护了,大部分代码都是参考了这个项目的Ruby代码用Go改写的。
主要的特点是根据Procfile格式批量管理应用进程,另外也可以支持运行多个不同目录里的项目进程。
在Linux系统环境执行下面的命令:
git clone https://github.com/gnuos/spm
cd spm
just
如果没有安装 just 这个工具,可以手动执行下面的命令进行编译:
go build -ldflags="-w -s -extldflags '-static'" -o ./bin/spm .
编译得到的 bin/spm 文件就是最终的单个二进制可执行文件,可以放在其他的PATH路径中便于使用。
在任意一个目录下面,放一个Procfile,参考 The Procfile 文章中的格式填写。
进入到存在 Procfile 文件的目录中,或者在命令参数里指定 Procfile 文件的位置和运行时的工作目录,就可以把项目运行到后台了。
执行后的效果如下所示:
$ ./bin/spm
Usage:
spm [flags]
spm [command]
Available Commands:
daemon Run supervisor as a daemon
help Help about any command
reload Reload processes and options
restart Restart processes
run Run command as a process
shutdown Stop supervisor
start Starts processes and/or the supervisor
status Check processed status
stop Stop processes
version Print version and exit
Flags:
-h, --help help for spm
-l, --loglevel string Set log Level (default "debug")
-p, --procfile string The path to the Procfile (default "/opt/spm/Procfile")
-v, --version Print version and exit
-w, --workdir string The path to the work directory (default "/opt/spm")
Use "spm [command] --help" for more information about a command.
在项目的 example 目录中,可以看到示例文件,以供参考。
Spm is licensed under the MIT license.
See LICENSE for the full license text.