决定看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的更多相关文章

  1. saltstack源码-启动3-config.py配置文件加载

    #目标文件位置/usr/lib/python2.6/site-packages/salt/config.py#这个文件加载配置文件的模块.master和minion的配置文件加载都是在这个模块里面完成 ...

  2. saltstack源码-启动2-parsers.py选项初始化1

    class MasterOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn, LogLevelMixIn, RunUserMixin ...

  3. saltstack源码详解一

    目录 初识源码流程 入口 1.grains.items 2.pillar.items 2/3: 是否可以用python脚本实现 总结pillar源码分析: @(python之路)[saltstack源 ...

  4. saltstack源码安装

    环境 centos6.3,python2.7.5. 1.install libzmq-master $ git clone git://github.com/zeromq/libzmq.git $ c ...

  5. 如何从源码启动和编译IoTSharp

    IoTSharp 项目是一个开源物联网平台,数据库使用PostgreSQL , 后端使用 Asp.Net Core 2.2 ,前端使用  vue-element-admin , 下面我们介绍如何启动项 ...

  6. Spring之SpringMVC(源码)启动初始化过程分析

    1.说明 SpringMVC作为Spring提供的MVC实现,可以实现与Spring的天然无缝联合,因为具有很广泛的用途.具体的关于SpringMVC的处理流程逻辑我在这里就不在赘述了.还是来通过源码 ...

  7. Derek解读Bytom源码-启动与停止

    作者:Derek 简介 Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom ...

  8. [日常] gocron源码阅读-使用go mod管理依赖源码启动gocron

    从 Go1.11 开始,golang 官方支持了新的依赖管理工具go modgo mod download: 下载依赖的 module 到本地 cachego mod edit: 编辑 go.modg ...

  9. bistoury的源码启动(二)

    bistoury.conf这个东东就是我们代码中的 -Dbistoury.conf=D:\openSource\bistoury\bistoury-proxy\conf 这样就能搞定了,一下子就能启动 ...

随机推荐

  1. MYSQL常见运算符和函数【重要】

    字符函数 (1)CONCAT():字符连接 SELECT CONCAT(‘IMOOC’,’-‘,’MySQL’);//IMOOC-MySQL SELECT CONCAT (first_name,las ...

  2. AtCoder Regular Contest 091&092

    091E(构造) 题意: 给出n,a,b.你需要构造出一个长度为n的n的排列,其中最长上升子序列的长度为a,最长下降子序列的长度为b. n,a,,b<=3e5 分析: 我们可以构造出这样的数列, ...

  3. SVN 学习笔记-高级操作

    所谓高级操作,只是曲高和寡,其实都不怎么用的.但是关键时候,可能会很有用. 这个高级只是针对基本操作而言.有些操作可能也是比较基本的. 清除锁 有时候我们在操作的时候,可能系统崩溃了,或者SVN非正常 ...

  4. lombok注解简化实体类getting 和 setting 方法

    实体类注解,将以往的get/set方法简化为标签注解,让代码看着更简洁. Maven依赖: <dependency> <groupId>org.projectlombok< ...

  5. PCRE函数简介和使用示例

    PCRE是一个NFA正则引擎,不然不能提供完全与Perl一致的正则语法功能.但它同时也实现了DFA,只是满足数学意义上的正则. PCRE提供了19个接口函数,为了简单介绍,使用PCRE内带的测试程序( ...

  6. 获取鼠标位置的几个通用的JS函数

    原文:http://www.open-open.com/code/view/1421401009218 /*两个通用函数,用于获取鼠标相对于整个页面的当前位置*/ function getX(e) { ...

  7. C# 读自己的资源文件

    Assembly assm = this.GetType().Assembly;//Assembly.LoadFrom(程序集路径); foreach (string resName in assm. ...

  8. 【转】PHP实现系统编程(四)--- 本地套接字(Unix Domain Socket)

    原文:http://blog.csdn.net/zhang197093/article/details/78143687?locationNum=6&fps=1 --------------- ...

  9. centos+nginx+php-fpm+php include fastcgi_params php页面能訪问但空白,被fastcgi_params与fastcgi.conf害慘了

    今天在centos上折腾这块是发现老是訪问页面时,浏览器中提示是200 ok.且訪问html后缀却是正常出现内容. 可是訪问php后缀却返回空白页面,同一时候查看全部的log没有发现不论什么出错信息; ...

  10. web.xml中的ServletContextListener

    要想了解ServletContextListener,先看看web.xml中的<listener>配置. 一)web.xml中的内容载入顺序: 首先能够肯定的是,载入顺序与它们在 web. ...