49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
""" Script to start and stop mandaye server
|
||
|
"""
|
||
|
|
||
|
import logging
|
||
|
|
||
|
from optparse import OptionParser
|
||
|
|
||
|
from mandaye import config
|
||
|
from mandaye import server
|
||
|
|
||
|
def get_cmd_options():
|
||
|
parser = OptionParser()
|
||
|
parser.add_option("--start",
|
||
|
dest="start",
|
||
|
default=False,
|
||
|
action="store_true",
|
||
|
help="Start Mandaye server"
|
||
|
)
|
||
|
parser.add_option("--stop",
|
||
|
dest="stop",
|
||
|
default=False,
|
||
|
action="store_true",
|
||
|
help="Stop the server"
|
||
|
)
|
||
|
parser.add_option("-d", "--daemon",
|
||
|
dest="daemon",
|
||
|
default=False,
|
||
|
action="store_true",
|
||
|
help="Daemonize the server"
|
||
|
)
|
||
|
(options, args) = parser.parse_args()
|
||
|
if options.start and options.stop:
|
||
|
parser.error("you can't use options start and stop at the same time")
|
||
|
if not options.start and not options.stop:
|
||
|
parser.error("You must use option start or stop")
|
||
|
return options
|
||
|
|
||
|
def main():
|
||
|
options = get_cmd_options()
|
||
|
if options.start:
|
||
|
logging.info("Starting Mandaye %s:%d .." % (config.host, config.port))
|
||
|
server.serve()
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|