root/openxcap

Revision 168, 1.8 kB (checked in by Adrian Georgescu <ag@ag-projects.com>, 2 weeks ago)

Update year

Line 
1#!/usr/bin/env python
2
3"""OpenXCAP"""
4
5
6if __name__ == '__main__':
7    import sys
8    from optparse import OptionParser
9    from application.process import process, ProcessError
10    from application import log
11
12    import xcap
13
14    name = 'openxcap'
15    fullname = 'Open XCAP'
16    description = 'An open source XCAP Server'
17
18    config_directory = '/etc/openxcap'
19    runtime_directory = '/var/run/openxcap'
20    default_pid = "%s/%s.pid" % (runtime_directory, name)
21
22    parser = OptionParser(version="%%prog %s" % xcap.__version__)
23    parser.add_option("--no-fork", action="store_false", dest="fork", default=1,
24                      help="run the process in the foreground (for debugging)")
25    parser.add_option("--pid", dest="pidFile", default=default_pid,
26                      help="pid file (%s)" % default_pid,
27                      metavar="File")
28
29    (options, args) = parser.parse_args()
30
31    pidFile = options.pidFile
32
33    process._system_config_directory = config_directory
34    try:
35        process.runtime_directory = runtime_directory
36    except ProcessError, e:
37        log.msg("Fatal error: %s" % e)
38        sys.exit(1)
39
40    if options.fork:
41        try:
42            process.daemonize(pidFile)
43        except ProcessError, e:
44            log.fatal(str(e))
45            sys.exit(1)
46        log.startSyslog(name)
47    else:
48        pass
49        #from application.debug.memory import *
50
51    print "Starting %s %s" % (fullname, xcap.__version__)
52
53    from xcap.server import XCAPServer
54    try:
55        server = XCAPServer()
56    except Exception, why:
57        print >>sys.stderr, "Failed to create Open XCAP: %s" % why
58        sys.exit(1)
59
60    try:
61        server.start()
62    except Exception, why:
63        print >>sys.stderr, "Failed to start Open XCAP: %s" % why
64        sys.exit(1)
Note: See TracBrowser for help on using the browser.