×

树莓派下实现ngrok自启动

穆琪 穆琪 发表于2018-12-06 15:49:53 浏览533 评论0

抢沙发发表评论

模仿服务来实现开机自启动

在/etc/systemd/system/目录下创建一个叫做ngrok.service的文件

写入以下代码:

[Unit]
Description=ngrok
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/ngrok -config=/root/ngrok/ngrok.conf start pan-ssh pi-ssh mac-ssh pi-vnc pan-http pi-http bt-http test-http  # 这一行是启动命令,适用于其他命令
[Install]
WantedBy=multi-user.target

使用方法:

运行ngroksystemctl 
start ngrok 
查询ngrok的运行状态
systemctl status ngrok 
实现开机自启动ngrok
systemctl enable ngrok