Frp后台自动启动的几个方法 supervisor 真棒

1使用nohup来启动

这是frps的后台启动(路径写你服务器上的绝对路径),如果要查看日志的话,就直接使用cat nohup.out,就可以查看了。

nohup /path/to/your/fprs -c-c /path/to/your/frps.ini

这是frpc的后台启动

nohup /path/to/your/fprc -c-c /path/to/your/frpc.ini

2使用systemctl来控制启动

这个方法比较好用,很方便
sudo vim /lib/systemd/system/frps.service
在frps.service里写入以下内容

[Unit]
Description=fraps service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/your/path/frps -c /your/path/frps.ini

[Install]
WantedBy=multi-user.target

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

然后就启动frps
sudo systemctl start frps
再打开自启动
sudo systemctl enable frps

  • 如果要重启应用,可以这样,sudo systemctl restart frps
  • 如果要停止应用,可以输入,sudo systemctl stop frps
  • 如果要查看应用的日志,可以输入,sudo systemctl status frps

3使用supervisor来控制

首先先安装supervisor,我用的ubuntu
sudo apt install supervisor
创建 supervisor frps 配置文件,在 /etc/supervisor/conf.d 创建 frp.conf

[program:frp]
command = /your/path/frps -c /your/path/frps.ini
autostart = true

 
 
  • 1
  • 2
  • 3

同样是你的绝对路径。
写完以后,要重新加载一下supervisor

# 重启supervisor
sudo systemctl restart supervisor
# 查看supervisor运行状态
sudo supervisorctl status

 
 
  • 1
  • 2
  • 3
  • 4

多说一句,这是写的frps的后台启动,frpc的话,类比一下就可以了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在CentOS中设置Supervisor开机自启可以按照以下步骤进行操作: 1. 打开Supervisor启动脚本文件: ```shell vim /etc/init.d/supervisord ``` 2. 在脚本文件中添加以下内容: ```shell #!/bin/bash # # supervisord Startup script for the Supervisor process control system # # chkconfig: - 64 36 # description: Supervisor is a client/server system to control \ # all processes on the local machine. # processname: supervisord # Source function library . /etc/rc.d/init.d/functions # Path to the supervisorctl script, server binary, # and short-form for messages. supervisorctl=/usr/local/bin/supervisorctl supervisord=${SUPERVISORD-/usr/local/bin/supervisord} prog=supervisord pidfile=${PIDFILE-/var/run/supervisord.pid} lockfile=${LOCKFILE-/var/lock/subsys/supervisord} STOP_TIMEOUT=${STOP_TIMEOUT-60} OPTIONS="${OPTIONS--c /etc/supervisord.conf}" RETVAL=0 start() { echo -n $"Starting $prog: " daemon --pidfile=${pidfile} $supervisord $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $supervisord RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -rf ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " LSB=1 killproc -p $pidfile $supervisord -HUP RETVAL=$? echo } restart() { stop start } case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $supervisord RETVAL=$? [ $RETVAL -eq 0 ] && echo || echo -n " not" ;; restart) restart ;; condrestart|try-restart) if status -p ${pidfile} $supervisord >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload}" RETVAL=2 esac exit $RETVAL ``` 3. 保存并退出文件。 4. 设置脚本文件的执行权限: ```shell chmod +x /etc/init.d/supervisord ``` 5. 启用Supervisor的开机自启: ```shell systemctl enable supervisord ``` 6. 验证Supervisor是否已经配置为开机自启: ```shell systemctl is-enabled supervisord ``` 如果输出结果为"enabled",则表示Supervisor已成功配置为开机自启。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值