示例#1
0
文件: demo.py 项目: nsi-iff/pyOLS
def fork_start_server():
    """ Fork and start the server, returning a function which can be
        used to kill off the child. """
    pid = os.fork()
    # If we are the parent, return
    if pid > 0:
        def dead_child(*args):
            print
            print "Failed to start server - "\
                  "is something else running on port 8000?"
            exit(4)
        signal.signal(signal.SIGCHLD, dead_child)
        # Give the server some time to start up
        time.sleep(2)

        def kill_child():
            os.kill(pid, signal.SIGTERM)
            os.wait()
        atexit.register(kill_child)
        return
    
    # The autoreloader causes strange problems when forking,
    # so we won't use it here.
    argv[1] = '-R'
    cmdline.run() # Start the server
示例#2
0
def fork_start_server():
    """ Fork and start the server, returning a function which can be
        used to kill off the child. """
    pid = os.fork()
    # If we are the parent, return
    if pid > 0:

        def dead_child(*args):
            print
            print "Failed to start server - "\
                  "is something else running on port 8000?"
            exit(4)

        signal.signal(signal.SIGCHLD, dead_child)
        # Give the server some time to start up
        time.sleep(2)

        def kill_child():
            os.kill(pid, signal.SIGTERM)
            os.wait()

        atexit.register(kill_child)
        return

    # The autoreloader causes strange problems when forking,
    # so we won't use it here.
    argv[1] = '-R'
    cmdline.run()  # Start the server
示例#3
0
文件: demo.py 项目: nsi-iff/pyOLS
def setup_environment():
    """ Setup a temporary environment, returning the directory name. """
    # A temporary directory which will be destoryed when the script exists
    dir = tempdir()

    # Create the environment
    argv[0] = 'pyols'
    argv.extend(['-c', dir])
    try: cmdline.run()
    except SystemExit: pass
    return dir
示例#4
0
def setup_environment():
    """ Setup a temporary environment, returning the directory name. """
    # A temporary directory which will be destoryed when the script exists
    dir = tempdir()

    # Create the environment
    argv[0] = 'pyols'
    argv.extend(['-c', dir])
    try:
        cmdline.run()
    except SystemExit:
        pass
    return dir
示例#5
0
#!/usr/bin/env python
""" This script is only to make it simple to get up-and-running
    with pyOLS.  It is recomended that pyOLS is run using the
    instructions in README.txt. """

from pyols import cmdline

cmdline.run()