我已经创建了服务文件:/usr/local/etc/rc.d/traefik
:
#!/bin/sh
#
. /etc/rc.subr
name=traefik
rcvar=traefik_enable
command="/usr/local/sbin/traefik"
command_args="--configFile=/usr/local/etc/traefik/config.toml"
pidfile="/var/run/${name}.pid"
traefik_enable="YES"
load_rc_config $name
run_rc_command "$1"
在输出中通过命令/usr/local/etc/rc.d/traefik start
调用服务时,正在打印:Starting traefik.
,但是进程未在后台加载。我必须单击CTRL + C才能终止进程,所以我无法管理traefik的服务。
如何将traefik作为后台进程运行?
答案 0 :(得分:0)
您可以使用daemon
来运行从控制终端分离的命令,因此您的rc.d
脚本可以是:
command="daemon /usr/local/sbin/traefik"
从男人那里:
The daemon utility detaches itself from the controlling terminal and exe-
cutes the program specified by its arguments. Privileges may be lowered
to the specified user. The output of the daemonized process may be redi-
rected to syslog and to a log file.
从手册页中检查选项,可能您想在终止后重新启动程序,为此,您可以使用选项-r
:
command="daemon -r /usr/local/sbin/traefik"
作为替代方案,也可以尝试对主管进行尝试。