syncthing部署记录,实现自启动及进程检查
分类:安装部署
6680
创建运行用户
安装
vim check_start.py
chmod +x ./check_start.py
添加到定时任务,一分钟检查一次脚本运行情况
8384 和 22000
哈哈哈哈 https://192.168.137.3:8384/ 访问不了
要配置一下,使用不只使用127.0.0.1
#如果不是当前用户,比如本文指定了syncthing_user,配置文件则生成于这个用户目录下
vim /home/syncthing_user/.config/syncthing/config.xml
127.0.0.1:8384
修改成
0.0.0.0:8384
重新运行一下syncthing
ps -ef | grep syncthing | grep -v grep | cut -c 9-15 | xargs kill 9
kill掉之后一分钟后会自动重新运行
启动后及时设置密码
useradd -m -s /bin/bash syncthing_user
passwd syncthing_user #创建密码
安装
wget http://www.isres.com/file/syncthing-linux-amd64-v0.14.43.tar.gz
tar -zxvf syncthing-linux-amd64-v0.14.43.tar.gzmv syncthing-linux-amd64-v0.14.43 /usr/local/syncthing
vim check_start.py
#!/usr/bin/python
#coding:utf-8
import os,time
#当前文件路径
current_path = os.getcwd()
log_file = current_path+'/check.log'
def is_runing(process_name):
try:
process = len(os.popen('ps aux | grep "' + process_name + '" | grep -v grep').readlines())
if process > 0:
return 1
else:
return 0
except:
return 0
def log(message):
os.popen('echo ['+time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))+'] '+message+' >> '+log_file)
proc_tag = '/usr/local/syncthing/syncthing'
if is_runing(proc_tag) == 0:
log('syncthing 进程没有运行或已停止!')
os.popen('/sbin/runuser -l syncthing_user -c '+proc_tag.replace('$','')+' >> /dev/null &')
else:
log('syncthing 正常')
chmod +x ./check_start.py
添加到定时任务,一分钟检查一次脚本运行情况
* * * * * python /usr/local/syncthing/check_start.py
8384 和 22000
哈哈哈哈 https://192.168.137.3:8384/ 访问不了
要配置一下,使用不只使用127.0.0.1
vim /home/syncthing_user/.config/syncthing/config.xml
#此文件运行时生成 ,或者有UI的linux用127.0.0.1在WEB界面修改IP也行。#如果不是当前用户,比如本文指定了syncthing_user,配置文件则生成于这个用户目录下
vim /home/syncthing_user/.config/syncthing/config.xml
127.0.0.1:8384
修改成
0.0.0.0:8384
重新运行一下syncthing
ps -ef | grep syncthing | grep -v grep | cut -c 9-15 | xargs kill 9
kill掉之后一分钟后会自动重新运行
启动后及时设置密码
setfacl -R -m u:syncthing_user:rxw /web/public_html/agentmanage
setfacl -R -d -m u:syncthing_user:rxw /web/public_html/agentmanage
#其中参数-n 为不重新计算mask ,移除参考如下
setfacl -R -x u:www /web/public_html/agentmanage/data/runtime/log #移除www用户的facl权限
[root@localhost]# ./syncthing --upgrade
13:37:25 INFO: Default folder created and/or linked to new config
13:37:27 INFO: Upgrade available (current "v0.14.43" < latest "v1.1.1")
13:37:35 INFO: Upgraded to "v1.1.1"
上一篇:Linux免密登录配置
下一篇:分享一个PC微信多开软件