Golang进程管理利器:Gosuv全方位解析
发表时间: 2024-06-13 21:20
github地址
https://github.com/codeskyblue/gosuv
中文文档
https://github.com/codeskyblue/gosuv/blob/master/README_ZH.md
一. 安装gosuv Git地址
从这里下载对应系统的二进制文件 不需要安装go语言环境
下载地址:
https://github.com/codeskyblue/gosuv/releases
gosuvmv gosuv /usr/bin
测试启动: gosuv start-server -f
将gosuv的二进制启动文件软链接到系统bin目录 ln -s gosuv /usr/local/bin
二. 将gosuv安装为linux的系统服务
1.编写systemd的单元配置文件 (启动命令ExecStart和启动路径WorkingDirectory酌情修改)
vim /usr/lib/systemd/system/gosuv.service[Unit]Description=gosuvAfter=syslog.targetAfter=network.target[Service]# Modify these two values and uncomment them if you have# repos with lots of files and get an HTTP error 500 because# of that####LimitMEMLOCK=infinity#LimitNOFILE=65535Type=simple # 如果要启动的命令是一个daemon进程, 这里的值设置为forkingUser=rootGroup=root# 可以将gosuv链接到bin目录或者直接移动到bin目录WorkingDirectory=/usr/bin# -f 参数指定gosuv前台启动,默认后台启动(如果没有-f参数, 则Type需要改为forking)ExecStart=/usr/local/bin/gosuv start-server -fRestart=always# Some distributions may not support these hardening directives. If you cannot start the service due# to an unknown option, comment out the ones not supported by your version of systemd.ProtectSystem=fullPrivateDevices=yesPrivateTmp=yesNoNewPrivileges=true[Install]WantedBy=multi-user.target
2. 将此文件放到
/usr/lib/systemd/system/gosuv.service 文件夹下, 此时就能够让服务开机启动和自动重启了
开放端口号
> # firewall-cmd --permanent --zone=public --add-port=11313/tcp> # firewall-cmd --reload
查看帮助
> # gosuv --help
开机启动: systemctl enable gosuv
启动服务: systemctl start gosuv
浏览器中访问: http//ip地址:11313