python开发mongodb启动脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

以上是关于python开发mongodb启动脚本的主要内容,如果未能解决你的问题,请参考以下文章

Python操作MongoDB

scrapy按顺序启动多个爬虫代码片段(python3)

如何将代码片段存储在 mongodb 中?

30 段 Python 实用代码

MongoDB Pymongo 问题

python 一个终端代码片段,在mac上生成可启动的usb live CD,以运行类似ubuntu或debian的内容。