需要将kcptun的服务端注册为系统服务,操作步骤如下:
将以下内容写入名为kcp.service的文件,并放到/usr/lib/systemd/system目录下
添加权限:chmod 777 kcp.service
[Unit]
Description=Kcptun Service
After=network.target
[Service]
User=root
Group=root
Type=simple
ExecStart=/home/zwt/kcp/server_linux_amd64 -t "127.0.0.1:5512" -l ":3512" -nocomp -mode fast3 -crypt salsa20 -key zhao1234
WorkingDirectory=/home/zwt/kcp
Restart=on-failure
[Install]
WantedBy=multi-user.target
注:ExecStart即为服务器程序的全路径,包含命令行参数。
设置开机启动:
systemctl enable kcp.service
启动服务:
systemctl start kcp.service