saltstack源码-启动1
决定看salt的源码了.干脆就从最基本的看起来,先看它的启动过程开始
第一步用/etc/init.d/salt-master start 启动
找到那个文件,发现有3种启动方式,suse,debian,centos的启动方式各不一样,我测试机和线上环境都是centos的,所以直接就看Centos的
......
PYTHON=/usr/bin/python
SALTMASTER=/usr/bin/salt-master
MASTER_ARGS=""
......
stat() {
......
elif $PYTHON $SALTMASTER -d $MASTER_ARGS >& /dev/null; then
echo -n "OK"
RETVAL=0
......
}
.......
从这个脚本看到其实就是执行了/usr/bin/salt-master 这个文件
继续往下查看文件 /usr/bin/salt-master
文件的全部类容就几行
#!/usr/bin/python
'''
Start the salt-master
'''
from salt.scripts import salt_master if __name__ == '__main__':
salt_master()
调用了salt.scripts下的salt_master 函数
找到目标文件和目标函数/usr/lib/python2.6/site-packages/salt/script.py
#!/usr/bin/python
import os
import sys # Import salt libs
import salt #包含本身的模块 路径:/usr/lib/python2.6/site-packages/salt/__init__.py
import salt.cli #这个暂时不知道干嘛的,以后再来分析 这个包含的路径是/usr/lib/python2.6/site-packages/salt/cli/__init__.py def salt_master():
'''
Start the salt-master.
'''
master = salt.Master()
master.start()
这里是调用了salt模块的Master类的start方法,我在salt目录下找了下没发现Master文件名相关的文件,那么一定就是在salt目录下的__init__.py文件里面
目标文件,目标类,目标类方法是在:/usr/lib/python2.6/site-packages/salt/__init__.py
class Master(parsers.MasterOptionParser):
'''
#这个类的继承是继承自/usr/lib/python2.6/site-packages/salt/utils/parser.py里面的
#这个parsers.py模块重写了自带的标准库optoarse.py的几个方法
Creates a master server
'''
def prepare(self):
'''
Run the preparation sequence required to start a salt master server. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).prepare()
'''
self.parse_args() try:
if self.config['verify_env']:
verify_env(
[
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'],
'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.join(self.config['cachedir'], 'proc'),
self.config['sock_dir'],
self.config['token_dir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
logfile = self.config['log_file']
if logfile is not None and not logfile.startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files([logfile], self.config['user'])
except OSError as err:
sys.exit(err.errno) self.setup_logfile_logger()
logger.info('Setting up the Salt Master') if not verify_socket(self.config['interface'],
self.config['publish_port'],
self.config['ret_port']):
self.exit(4, 'The ports are not available to bind\n')
self.config['interface'] = ip_bracket(self.config['interface'])
migrations.migrate_paths(self.config) # Late import so logging works correctly
import salt.master
self.master = salt.master.Master(self.config)
self.daemonize_if_required()
self.set_pidfile() def start(self):
'''
Start the actual master. If sub-classed, don't **ever** forget to run: super(YourSubClass, self).start() NOTE: Run any required code before calling `super()`.
'''
self.prepare() #这里调用自己的prepare的方法
if check_user(self.config['user']):
try:
self.master.start()
except MasterExit:
self.shutdown()
finally:
sys.exit() def shutdown(self):
'''
If sub-classed, run any shutdown operations on this method.
'''
一路追查下去,发现我2个24寸的显示器根本不够用,涉及的文件模块太多了
我都开始怀疑我到底是不是会python,我感觉我根本就没接触过python.....
我又恶补了一下关于python类的知识和optparse标准库
好吧,先休息一会出去走一下,放松自己凌乱的脑袋
saltstack源码-启动1的更多相关文章
- saltstack源码-启动3-config.py配置文件加载
#目标文件位置/usr/lib/python2.6/site-packages/salt/config.py#这个文件加载配置文件的模块.master和minion的配置文件加载都是在这个模块里面完成 ...
- saltstack源码-启动2-parsers.py选项初始化1
class MasterOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn, LogLevelMixIn, RunUserMixin ...
- saltstack源码详解一
目录 初识源码流程 入口 1.grains.items 2.pillar.items 2/3: 是否可以用python脚本实现 总结pillar源码分析: @(python之路)[saltstack源 ...
- saltstack源码安装
环境 centos6.3,python2.7.5. 1.install libzmq-master $ git clone git://github.com/zeromq/libzmq.git $ c ...
- 如何从源码启动和编译IoTSharp
IoTSharp 项目是一个开源物联网平台,数据库使用PostgreSQL , 后端使用 Asp.Net Core 2.2 ,前端使用 vue-element-admin , 下面我们介绍如何启动项 ...
- Spring之SpringMVC(源码)启动初始化过程分析
1.说明 SpringMVC作为Spring提供的MVC实现,可以实现与Spring的天然无缝联合,因为具有很广泛的用途.具体的关于SpringMVC的处理流程逻辑我在这里就不在赘述了.还是来通过源码 ...
- Derek解读Bytom源码-启动与停止
作者:Derek 简介 Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom ...
- [日常] gocron源码阅读-使用go mod管理依赖源码启动gocron
从 Go1.11 开始,golang 官方支持了新的依赖管理工具go modgo mod download: 下载依赖的 module 到本地 cachego mod edit: 编辑 go.modg ...
- bistoury的源码启动(二)
bistoury.conf这个东东就是我们代码中的 -Dbistoury.conf=D:\openSource\bistoury\bistoury-proxy\conf 这样就能搞定了,一下子就能启动 ...
随机推荐
- codeforces #301 div2
A:简单题 每次判断向上转快,还是向下转快即可 #include <cstdio> #include <cstring> #include <iostream> # ...
- Linux怎么读? Linux读音考古一日游
Linux怎么读? Linux读音考古一日游/*凡是准备踏入Linux大门的叉子们(N年不关注了,不知道这个称呼是否还有),都必须经历疑问 那就是linux到底怎么读? 也许有些人很容易 什么里纽克 ...
- sequence(bzoj 1367)
Description Input Output 一个整数R Sample Input 794820141518 Sample Output 13 HINT 所求的Z序列为6,7,8,13,14,15 ...
- Codevs 二叉树遍历问题 合集
2010 求后序遍历 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 白银 Silver 题目描述 Description 输入一棵二叉树的先序和中序遍历序列,输出其后序遍历序列. ...
- hdu3622 2-sat问题,二分+判断有无解即可。
/*2-sat问题初破!题意:每一对炸弹只能选一个(明显2-sat),每个炸弹半径自定,爆炸范围不可 相交,求那个最小半径的最大值(每种策略的最小半径不同).思:最优解:必然是选择的点最近 的俩个距离 ...
- POJ 1144 割点
题意 :求割点的数量 #include<iostream> #include<stdio.h> #include<vector> #include<strin ...
- Codeforces 659E New Reform【DFS】
题目链接: http://codeforces.com/problemset/problem/659/E 题意: 给定n个点和m条双向边,将双向边改为单向边,问无法到达的顶点最少有多少个? 分析: 无 ...
- noip 2015 day1
T1 神奇的幻方 题目描述 幻方是一种很神奇的N*N矩阵:它由数字1,2,3,……,N*N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个幻方: 首先将1 ...
- Fortinet网络接入及安全方案配置步骤
http://sec.chinabyte.com/200/12553700.shtml 1.概述: Fortinet无线接入及方案由以下两类设备组成: AC(Wifi接入控制器)及安全网关:Forti ...
- Cts框架解析(6)-任务的运行
前两篇讲了任务的加入和9大项配置,这篇讲任务的运行. 任务的运行 任务的运行在CommandScheduler的run方法中,所以删除全部的断点,在run方法中打上断点,重新启动启动debug: 先看 ...