kahgean / test / simple_daemon.py

"""A simple XML-RPC Server for test_daemonize.py"""

import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from SimpleXMLRPCServer import SimpleXMLRPCServer
from kahgean.options import Options
from kahgean import initial
from kahgean import logkit
from kahgean import daemonize

def getpid():
    return os.getpid()

def ping():
    return 'pong'


if __name__ == '__main__':
    options = Options()
    options.add_option('--port', type=int, default=38080)
    initial.append_options(options)
    logkit.append_options(options)
    daemonize.append_options(options)
    options.parse_options()
    initial.deal_with_options(options)
    logkit.deal_with_options(options)
    daemonize.deal_with_options(options)
    server = SimpleXMLRPCServer(("localhost", options.get('port')))
    server.register_function(getpid, 'getpid')
    server.register_function(ping, 'ping')
    server.serve_forever()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.