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 这样就能搞定了,一下子就能启动 ...
随机推荐
- [luoguP2704] 炮兵阵地(状压DP)
传送门 可以事先把每一行的所有状态处理出来,发现每一行的状态数最多不超过60个 f[i][j][k]表示前i行,第i行为状态j,第i-1行为状态k的最优解 #include <vector> ...
- bzoj1708 [Usaco2007 Oct]Money奶牛的硬币 背包dp
[Usaco2007 Oct]Money奶牛的硬币 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 852 Solved: 575[Submit][Sta ...
- android L版本AAL新架构
[DESCRIPTION] 和之前KK版本相比,在L版本上面AAL的架构也有发生一些改变. 拿掉了之前KK平台上使用的MTK LABC,使用Android原生的自动背光功能. AALService内部 ...
- Treasure Hunt--poj1066(最短路加判断线段的关系)
http://poj.org/problem?id=1066 题目大意:有n条线段 他们都在这个房间里 最后有一个点代表起始位置 现在想通过墙出去 他只能爆破每个房间的中点的门 问最少的门通 ...
- 动态规划:HDU 1114 Piggy-Bank
Problem Description Before ACM can do anything, a budget must be prepared and the necessary financia ...
- QT程序--小工具集合
这是在大一第一学期时写的参加程序设计大赛的作品,当时参加的时候仅仅只有贪吃蛇,迷宫算法和文件加密这三个功能,而且当时的界面并没有进行任何美化,现在想起来有点可惜.然而这并不是一个只写一遍的软件,在后期 ...
- iphone5s 耳机更换插头 EarPods change jack
iphone5s 耳机使用了不到两年,出现了接头接触不良,话筒线短路的状况,经常自动出现暂停或者siri.买了一个新耳机,这几天有时间,把旧耳机修好了,更换了一个新的插头. 工具/原料 剥线钳 ...
- 共享内存mmap学习 及与 shmxxx操作的区别
上一篇学习了共享内存: http://www.cnblogs.com/charlesblc/p/6142139.html 根据这个 http://blog.chinaunix.net/uid-2633 ...
- Use JavaScript to Export Your Data as CSV
原文: http://halistechnology.com/2015/05/28/use-javascript-to-export-your-data-as-csv/ --------------- ...
- MIT 操作系统实验 MIT JOS lab1
JOS lab1 首先向MIT还有K&R致敬! 没有非常好的开源环境我不可能拿到这么好的东西. 向每个与我一起交流讨论的programmer致谢!没有道友一起死磕.我也可能会中途放弃. 跟丫死 ...