一、公司的类似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

021_supervise进行管理利器的更多相关文章

  1. [转]Linux后台进程管理利器:supervisor

    FROM : http://www.liaoxuefeng.com/article/0013738926914703df5e93589a14c19807f0e285194fe84000 Linux后台 ...

  2. Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET

    Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET undefined Package - crawler undefined 科学网- ...

  3. KVM镜像管理利器-guestfish使用详解

    原文  http://xiaoli110.blog.51cto.com/1724/1568307   KVM镜像管理利器-guestfish使用详解 本文介绍以下内容: 1. 虚拟机镜像挂载及w2k8 ...

  4. linux下远程管理利器-tmux

    linux下远程管理利器-tmux 1.控制键       控制键就是tmux的主键.当你在tmux环境下按下这个键的时候,tmux就会把你后面输入的指令,解析成它内置的功能.tmux默认的控制键是 ...

  5. scribefire 多博客管理利器 安装详解

    scribefire 多博客管理利器 安装详解 一.ScribeFire介绍 ScribeFire 是 Firefox (火狐浏览器)上著名的博客写作工具,目前已跨平台支持多浏览器(Firefox,C ...

  6. MAC上的包管理利器

    Homebrew- MAC上的包管理利器 2013-07-01 16:25 by 黄博文, 76 阅读, 0 评论, 收藏, 编辑 包管理器是神马东西?让我们看看wikipedia上的介绍. In s ...

  7. 【干货】快速部署微软开源GPU管理利器: OpenPAI

    [干货]快速部署微软开源GPU管理利器: OpenPAI 介绍 不管是机器学习的老手,还是入门的新人,都应该装备上尽可能强大的算力.除此之外,还要压榨出硬件的所有潜力来加快模型训练.OpenPAI作为 ...

  8. SDK管理利器——sdkman

    SDK管理利器--sdkman 项目使用java的开发者一定会为新配环境变量而头大,sdkman很好的解决了系统sdk管理的痛点,仅需简单的几行命令就可以完成sdk的安装,更改默认版本.再也不用担心环 ...

  9. nrm npm源管理利器

    nrm npm源管理利器 nrm是管理npm源的一个利器. 有时候我们用npm install 安装依赖时会非常的慢,是官方自身的npm本来就慢,然后我们会尝试安装淘宝的npm或者cnpm,这些安装切 ...

随机推荐

  1. IntelliJ IDEA 2017 配置Tomcat 运行Web项目

    以前都用MyEclipse写程序的 突然用了IDEA各种不习惯的说 借鉴了很多网上好的配置办法,感谢各位大神~ 前期准备 IDEA.JDK.Tomcat请先在自己电脑上装好 好么~ 博客图片为主 请多 ...

  2. windows server 禁用智能卡服务的步骤

    许多用户对于系统中的很多功能都不太了解,其中智能卡服务更是少有人知.智能卡服务就是对插入的智能卡进行管理和访问控制,大多数用户都无需使用此项功能.那么在Win7系统中要怎么取消智能卡服务呢? 1.首先 ...

  3. 一个awk if 嵌套 if 的脚本

    [root@makeISO sjx]# cat sex.sh #!/bin/bash # 统计如下内容,并输出结果 # (男职工未婚数量/男员工整体数量)(女员工未婚数量/女员工整体数量) echo ...

  4. IIS7.5配置过程

    1.Windows功能,注意选择应用程序开发功能,否则不能使用经典模式. 2.Cmd运行(使用.netframework4.0)C:\Windows\Microsoft.NET\Framework\V ...

  5. 二十八、Linux 进程与信号---前台进程组

    28.1 介绍 28.1.1 概念 自动接受终端信号的组称为前台进程组 在终端通过 ctrl + c 等动作产生的信号首先被前台进程组接受 在 shell 启动的若干个进程组默认是父进程所在的组为前台 ...

  6. 大规模数据导入和导出(sqlserver)

    请期待... https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools#RHEL msodbcsql-13.1.6 ...

  7. luogu 4377 Talent show 01分数规划+背包dp

    01分数规划+背包dp 将分式下面的部分向右边挪过去,通过二分答案验证, 注意二分答案中如果验证的mid是int那么l=mid+1,r=mid-1,double类型中r=mid,l=mid; 背包dp ...

  8. 用Windows Media Service打造的流媒体点播

    所谓流媒体是指采用流式传输的方式在Internet播放的媒体格式.和需要将整个视频文件全部下载之后才能观看的传统方式相比,流媒体技术是通过将视频文件经过特殊的压缩方式分成一个个的小数据包,由视频服务器 ...

  9. Git学习之忽略特殊文件.gitignore的配置

    1.Mac中使用Git上传项目代码时忽略.DS_Store文件 简单的说Mac每个目录都会有个文件叫.DS_Store,它是用于存储当前文件夹的一些Meta信息.所以每次查看Git目录的状态,如果没有 ...

  10. Kaldi的交叉熵正则化

    xent_regularize, Cross Entropy Regularize nnet3/nnet-discriminative-trainning.cc:109 void NnetDiscri ...