若是用作好的安装包安装Openstack,启动服务必定会想到用service nova-${api,network,compute}之类的,可是若是单纯从lanuchpad,github上下载源码安装呢,就没办法。不过对照分析仍是能够得出不少小技巧。python
就拿nova-api这个模块来举例:linux
(1)cat /etc/init.d/nova-api 这个就是service nova-api ${restart,start,stop}要用的脚本,关键代码以下:git
/sbin/start-stop-daemon --start -b -c nova:nobody --make-pidfile --pidfile /var/run/nova/nova-api.pid --exec /usr/bin/nova-api -- --flagfile=/etc/nova/nova.conf --log-file=/var/log/nova/nova-api.log github
其实就是用start-stop-daemon去调用 /usr/bin/nova-api 而后给必定的参数。api
(2)查看/usr/bin/nova-apiui
#!/usr/bin/python
# EASY-INSTALL-SCRIPT: 'nova==2012.2','nova-api'
__requires__ = 'nova==2012.2'
import pkg_resources
pkg_resources.run_script('nova==2012.2', 'nova-api')spa
原来是运行了 nova egg包里面的脚本 nova-api,rest
可贵找路径,执行以下看看:orm
[root@xgtest nova]# python
Python 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nova
>>> print nova.__path__
['/usr/lib/python2.6/site-packages/nova-2012.2-py2.6.egg/nova']
>>> ip
在这里能够找到脚本:'/usr/lib/python2.6/site-packages/nova-2012.2-py2.6.egg/
[root@xgtest scripts]# pwd
/usr/lib/python2.6/site-packages/nova-2012.2-py2.6.egg/EGG-INFO/scripts
[root@xgtest scripts]#
[root@xgtest scripts]#
[root@xgtest scripts]# ll
total 152
-rw-r--r--. 1 root root 2659 Aug 22 11:16 nova-all
-rw-r--r--. 1 root root 1705 Aug 22 16:58 nova-api
-rw-r--r--. 1 root root 1470 Aug 22 11:16 nova-api-ec2
...............................
这就是咱们要的nova-api脚本,这个脚本是干什么的,是另一个topic了..