一、公司的类似ansible的工具也是用supervise管理的

[admin@mjyall-test-1 /service/ansible-oc-agent]$ ps -ef|grep 19070
root 19070 19068 0 00:44 ? 00:00:00 svscan /service
root 19072 19070 0 00:44 ? 00:00:00 supervise ansible-oc-agent
root 19073 19070 0 00:44 ? 00:00:00 supervise log
[admin@mjyall-test-1 /service/ansible-oc-agent]$ sudo tree .
.
├── log
│   ├── run
│   └── supervise
│   ├── control
│   ├── lock
│   ├── ok
│   └── status
├── run
└── supervise
├── control
├── lock
├── ok
└── status 3 directories, 10 files
[admin@mjyall-test-1 /service/ansible-oc-agent]$ cat run
#!/bin/bash . /etc/profile mkdir -p /opt/ansible-oc-agent/cache
cd /opt/eoc-agent exec 2>&1
exec /opt/ansible-oc-agent/bin/startup.sh

二、常用命令集合。

#官网:https://cr.yp.to/daemontools/svc.html
svc -d /service/eoc-agent && sleep 10  &&  svc -k /service/eoc-agent  && svc -u /service/eoc-agent #重启eoc-agent
svstat /service/eoc-agent #查看jyalloc-agent状态
   svc -d /service/eoc-agent  关闭
   svc -u /service/eoc-agent  打开

三、daemontools自带命令详解

[root@xxx-opstools-2 /opt/ops/cmdb]# rpm -ql daemontools
/usr/bin/envdir
/usr/bin/envuidgid
/usr/bin/fghack
/usr/bin/multilog
/usr/bin/pgrphack
/usr/bin/readproctitle
/usr/bin/setlock
/usr/bin/setuidgid
/usr/bin/softlimit
/usr/bin/supervise
/usr/bin/svc
/usr/bin/svok
/usr/bin/svscan
/usr/bin/svscanboot
/usr/bin/svstat
/usr/bin/tai64n
/usr/bin/tai64nlocal
cat /usr/lib/systemd/system/daemontools.service systemctl status daemontools #查看通过daemontools控制的服务的状态

[Unit]
   Description=daemontools
   After=sysinit.target

[Service]
   ExecStart=/usr/bin/svscanboot
   Restart=always

[Install]
   WantedBy=multi-user.target

(1)envdir   设置环境变量用的, Reference:https://cr.yp.to/daemontools/envdir.html

(2)envuidgid  设置运行脚本的uid and gid, Reference:https://cr.yp.to/daemontools/envuidgid.html

(3)fghack   fghack is an anti-backgrounding tool.   Reference:https://cr.yp.to/daemontools/fghack.html

(4)multilog  multilog reads a sequence of lines from stdin and appends selected lines to any number of logs.

root      2386  2384  0  2017 ?        00:00:25 multilog t s10485760 n5 /opt/eoc-agent/logs

<1>解释下这里"t"时间戳的意义:

Timestamping
The action
t
inserts an @, a precise timestamp, and a space in front of each line, using the same format as tai64n. This is required to be the first action.
Patterns apply to the line after the timestamp is inserted. For example, if multilog t '-*' '+* fatal: *' ./main
reads the line
fatal: out of memory
then it will log a line such as
@400000003b4a39c23294b13c fatal: out of memory
with the first * matching the timestamp.
You can use tai64nlocal to convert these timestamps to human-readable form.

<2>Automatically rotated logs日志文件解释

日志文件大小size must be between 4096 and 16777215. The default maximum file size is 99999.单位为byte

@表示已经写完的老的文件,current表示当前正在写的

.s: This file is completely processed and safely written to disk.
.u: This file was being created at the moment of an outage. It may have been truncated. It has not been processed.

(5)pgrphack    pgrphack runs a program in a separate process group.

(6)readproctitle maintains an automatically rotated log in memory for inspection by ps.

(7)setlock runs another program with a file locked.

(8)setuidgid runs another program under a specified account's uid and gid.

(9)softlimit runs another program with new resource limits.

(10)supervise starts and monitors a service.

也可以用svc()进行启动<https://cr.yp.to/daemontools/svc.html>.

状态查看使用svstat()<https://cr.yp.to/daemontools/svstat.html>.

svok检查是否服务是ok的<https://cr.yp.to/daemontools/svok.html>.

svscan to reliably start a collection of supervise processes(批量启动supervisor服务,上限为1000个子目录,而且它是永久启动的,并且会不断扫描新的目录)<https://cr.yp.to/daemontools/svscan.html>.

(11)启动服务

svscanboot starts svscan in the /service directory

(12) tai64n puts a precise timestamp on each line.

(13)tai64nlocal converts precise TAI64N timestamps to a human-readable format.

If a line begins with @, tai64nlocal looks for a timestamp after the @, in the format printed by tai64n, and writes the line to stdout with the timestamp converted to local time in ISO format: YYYY-MM-DD HH:MM:SS.SSSSSSSSS.

Reference:

https://cr.yp.to/daemontools.html

https://isotope11.com/blog/manage-your-services-with-daemontools

https://blog.csdn.net/u012373815/article/details/70217030

最新文章

  1. JQery判断checkbox是否被选三种方式
  2. 20145229&amp;20145316《信息安全系统设计基础》实验一 开发环境的熟悉
  3. zw版【转发&#183;台湾nvp系列Delphi例程】HALCON SmoothImage
  4. mysql新建用户本地无法登录
  5. iOS中UITextView键盘回收
  6. 如何通过shell脚本操作MongoDB
  7. 《Java并发编程实战》第二章 线程安全 札记
  8. 常用的js事件
  9. 验证代理IP
  10. Mybatis源码之Statement处理器StatementHandler(一)
  11. Object.freeze(); 方法冻结一个对象。
  12. UVA 11613 Acme Corporation(不固定流量的最小费用流)
  13. Windows下配置Django环境
  14. sudo: /etc/sudoers is world writable sudo: no valid sudoers sources found, q...
  15. ORACLE基本操作备忘
  16. 三 oracle 用户管理一
  17. [转]Handler学习笔记(一)
  18. FTP服务器配置实践
  19. python中json库中的load、loads、dump、dumps的区别与用法
  20. ionic 环境搭建

热门文章

  1. layui打印html页面转成pdf
  2. 爬虫基础02-day24
  3. Sql显示16进制
  4. Reduce:规约;Collector:收集、判断性终止函数、组函数、分组、分区
  5. 堆栈Stack介绍
  6. [C++]动态规划系列之币值最大化
  7. ThinkPHP5基础学习
  8. Python11 RabbitMQ Redis
  9. 编写blog第一天
  10. A Simple Problem with Integers POJ - 3468 (分块)