python開發mongodb啓動腳本

#!/usr/bin/env python
#coding:utf-8

import os
import sys

def start():
    os.system('/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongodb.conf')

def stop():
    os.system('/usr/local/mongodb/bin/mongod --shutdown --dbpath /data/mongodb/db')

def status():
    os.system('ps aux | grep mongod | grep -v grep')

def callable(input_key):
    service_option = {'start': start, 'stop': stop, 'status': status}
    return service_option[input_key]()

input_key=sys.argv[1]
callable(input_key)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章