Skip to content

在Linux下如何将XX Net作为后台服务启动

yoke88 edited this page Jul 30, 2016 · 10 revisions

#把 XX-Net 作为后台服务启动

如果希望把XX-Net作为服务启动,XX-net 其实已经提供了sysv的启动脚本。假设你的XX-Net 的目录在/home/yourName/XX-Net,那么在/etc/init.d 目录下执行

sudo ln -s /home/yourName/XX-Net/code/default/xx_net.sh xx_net

_Tips: 如果你发现使用上面超链接的方式,在系统启动时xx_net的服务起不来,但是使用sudo service xx_net start 却可以启动服务,而在dmesg|grep xx_net 时,会发现有/etc/init.d/xx_net no such file or directory 的错误,那你可能遇到了systemd 的bug,解决办法是拷贝/home/yourName/XX-Net/code/default/xx_net.sh 到 /etc/init.d/xx_net ,然后修改/etc/init.d/xx_net 里的$PACKAGE_PATH='/home/yourName/XX-Net/code/default' _

如果系统使用systemD 进行服务管理,则执行下面命令启用xx_net服务:

sudo systemctl enable xx_net

如果你是debian的系统,则使用下面命令启用xx_net服务:

sudo update-rc.d enable xx_net 

启动xx-net:

sudo service xx_net start

停止xx-net:

sudo service xx_net stop

重启xx-net:

sudo service xx_net restart

查看XX-net状态:

sudo service xx_net status

也或者用下面命令更靠谱些:

sudo netstat -tlanp|grep 8087

日志保存在/var/log/messages文件中,用tail命令查看:

tail -f /var/log/messages|grep xx_net

关于 Fedora

目前,主流发行版均使用 Systemd init 管理系统服务。 Fedora 用户可添加 FZUG 源,安装 xx-net 并使用 systemd 管理。

启动xx-net:

$ systemctl --user start xx-net

查看状态:

$ systemctl --user status xx-net

停止xx-net:

$ systemctl --user stop xx-net

使用 systemctl 用户模式管理,而无需用 root 权限运行,提高安全性。

Clone this wiki locally