init script
/etc/init.d/clash
#!/sbin/openrc-run
pidfile="/run/$RC_SVCNAME.pid"
command="/usr/bin/clash"
command_args="-d /etc/clash"
command_user="root"
depend() {
need net
}
start() {
ebegin "Starting $RC_SVCNAME"
start-stop-daemon --background \
--exec $command \
--make-pidfile --pidfile $pidfile --user $command_user \
--start -- $command_args
eend $?
}
stop() {
ebegin "Stopping $RC_SVCNAME"
start-stop-daemon --stop \
--exec $command \
--pidfile $pidfile --user $command_user
eend $?
}
reload() {
ebegin "Reloading $RC_SVCNAME"
start-stop-daemon --exec $command \
--pidfile $pidfile --user $command_user \
-s 1
eend $?
}
chmod +x /etc/init.d/myapp
/etc/init.d/myapp start
/etc/init.d/myapp stop
#开机启动
rc-update add myapp default
# 确认服务开机自启动状态
rc-update
rc-status