这是一个创建于 2841 天前的主题,其中的信息可能已经有所发展或是发生改变。
主要问题:怎么能让 frps 在后台运行(开机自启动)?
描述:
系统是 centos 5 32 位
frp 是最新版本
frps 配置好后, frps 位于 /usr/bin/, frps.ini 位于 /etc/frps/
然后运行 frps -c /etc/frps/frps.ini 正常。
不过有个问题,关闭 ssh 会话后, frps 就退出了
为了能在后台运行我尝试了 screen ,确实能工作,不过我想重启之后依然能自动启动
我寻思自己写一个服务脚本放在 /etc/ini.d/下:
#!/bin/bash
#
# Comments to support chkconfig
# chkconfig: - 98 02
# description: frps service script
#
# Source function library.
. /etc/init.d/functions
### Default variables
prog_name="frps"
prog_path="/usr/bin/${prog_name}"
pidfile="/var/run/${prog_name}.pid"
options="-c /etc/frps/frps.ini"
# Check if requirements are met
[ -x "${prog_path}" ] || exit 1
RETVAL=0
start(){
echo -n $"Starting $prog_name: "
daemon $prog_path $options
RETVAL=$?
PID=$(pidof ${prog_path})
[ ! -z "${PID}" ] && echo ${PID} > ${pidfile}
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog_name
return $RETVAL
}
stop(){
echo -n $"Shutting down $prog_name: "
killproc -p ${pidfile}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog_name
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status $prog_path
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
-----------------------------------------------------------------分割线--------------------------------------------------------------------
运行 service frps start 的时候,卡在了 daemon $prog_path $options 这里(本来正常情况下会 echo [ok]的),不过此时 frps 是在正常运行的, Dashboard 能正常打开。
然后想请教大家有没有能让 frps 在后台运行又能开机自启的方案?
7 条回复 • 2017-01-13 13:42:32 +08:00
|
|
1
WildCat 2017-01-11 14:59:54 +08:00 via iPhone
Linux service 有点复杂, supervisor 简单一些
|
|
|
2
mistak1992 2017-01-11 15:09:31 +08:00
@ WildCat Soga 我试试装这个去,这个系统太旧了 centos5 的,好多软件都装不上了,手动安装也不能解决依赖关系~不知道能不能装上囧
|
|
|
3
mkeith 2017-01-11 17:00:50 +08:00
monit 不需要 python 环境
|
|
|
4
yuchenr 2017-01-11 17:03:52 +08:00
@ WildCat supervisor +1 或者直接扔 rc.loacl
|
|
|
5
ryd994 2017-01-11 22:32:59 +08:00 via Android
CentOS5 ……… 为什么还要用这种停止支持的 上 CentOS7 用 systemd 啊
|
|
|
6
Rocko 2017-01-11 22:38:11 +08:00
supervisor or systemd
|