决定看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. 什么是Istio

    本文主要是对Istio Prelim 1.0(https://preliminary.istio.io/docs/)的翻译 Istio:一种开放式平台,用于连接,管理和保护微服务. Istio提供了一 ...

  2. X230 安装 EI Capitan 10.11.5 总结

    /*     写这个文章的目的主要是为了帮助我自己理清思路,如果能顺便帮助到您.even better   */ 在动手之前大致浏览了 远景论坛(国内第一黑苹果社区)置顶帖的全部内容 [新人请看]远景 ...

  3. 【HDOJ6318】Swaps and Inversions(树状数组)

    题意: 给定一串数组,其中含有一个逆序对则需要花费x,交换相邻两个数需要花费y,输出最小花费. n<=1e5,-1e9<=a[i]<=1e9 思路: #include<cstd ...

  4. C#特性入门《详解》

    原文发布时间为:2008-11-22 -- 来源于本人的百度文章 [由搬家工具导入] <转>http://www.bccn.net/Article/net/cs/jszl/200709/6 ...

  5. hdu 4046 Panda [线段树]

    Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Subm ...

  6. 《APP开发》APP规范实例-详细的UI设计方法

    对了一个APP开发初手来说,可能心里有很多的疑惑: 屏幕设计为多宽,宽度是不是应该设置为百分比; 按钮大小多大,怎么排列,文字字体用多大的?什么字体显示好看?图标多大,怎么用色?界面怎么布局?等等很多 ...

  7. ACM-ICPC 2018 焦作赛区网络预赛 H、L

    https://nanti.jisuanke.com/t/31721 题意 n个位置 有几个限制相邻的三个怎么怎么样,直接从3开始 矩阵快速幂进行递推就可以了 #include <bits/st ...

  8. Java描述符(修饰符)的类型

    以下内容引用自http://wiki.jikexueyuan.com/project/java/modifier-types.html: 描述符(修饰符)是添加到那些定义中来改变他们的意思的关键词.J ...

  9. Linux下的lds链接脚本简介(一)

    转载自:http://linux.chinaunix.net/techdoc/beginner/2009/08/12/1129972.shtml 一. 概论 每一个链接过程都由链接脚本(linker ...

  10. Python访问MySQL数据库并实现其增删改查功能

    概述:对于访问MySQL数据库的操作,我想大家也都有一些了解.不过,因为最近在学习Python,以下就用Python来实现它.其中包括创建数据库和数据表.插入记录.删除记录.修改记录数据.查询数据.删 ...