示例#1
0
文件: startup.py 项目: 0-T-0/TACTIC
        print 
        print "You should not run this as root. Run it as the Web server process's user. e.g. apache"
        print
        sys.exit(0)

    thread_count = Config.get_value("services", "thread_count") 
    

    import cherrypy
    if cherrypy.__version__.startswith("3."):
        if not thread_count:
            thread_count = 50
        else: 
            thread_count = int(thread_count)
        from pyasm.web.cherrypy30_startup import CherryPyStartup
        startup = CherryPyStartup(port)
        startup.set_config('global', 'environment', 'production')
        
        startup.set_config('global', 'server.socket_port', port)
        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', thread_count)
        
        startup.set_config('global', 'log.screen', True)
        # the access log is not completely redirected to std.out so the following is needed
        # but having just URL access time alone is pointless as well. commented out for now
        #startup.set_config('global', 'log.access_file', '%s/tactic_access.log'%log_dir)
        startup.set_config('global', 'request.show_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

    else:
示例#2
0
            else:
                print "The file should be owned by the same user that runs this startup_dev.py process."
            sys.exit(2)



    if os.name != 'nt' and os.getuid() == 0:
        print 
        print "You should not run this as root. Run it as the Web server process's user. e.g. apache"
        print 
        sys.exit(0)

    import cherrypy
    if cherrypy.__version__.startswith("3."):
        from pyasm.web.cherrypy30_startup import CherryPyStartup
        startup = CherryPyStartup(port)

        startup.set_config('global', 'server.socket_port', port)
        
        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', 50)
        #startup.set_config('global', 'server.socket_host', server)

        startup.set_config('global', 'log.screen', True)

        startup.set_config('global', 'request.show_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

        startup.set_config('global', 'engine.autoreload_on', True)

示例#3
0
def do_startup(port, server=""):

    #from tactic.startup import FirstRunInit
    #cmd = FirstRunInit()
    #cmd.execute()

    if os.name != 'nt' and os.getuid() == 0:
        print 
        print "You should not run this as root. Run it as the Web server process's user. e.g. apache"
        print
	return

    thread_count = Config.get_value("services", "thread_count") 
    

    if not thread_count:
        thread_count = 10
    else: 
        thread_count = int(thread_count)


    from pyasm.web.cherrypy30_startup import CherryPyStartup
    startup = CherryPyStartup()

    startup.set_config('global', 'server.socket_port', port)

    startup.set_config('global', 'server.socket_queue_size', 100)
    startup.set_config('global', 'server.thread_pool', thread_count)
    #startup.set_config('global', 'server.socket_host', server)

    #startup.set_config('global', 'log.screen', True)

    startup.set_config('global', 'request.show_tracebacks', True)
    startup.set_config('global', 'server.log_unhandled_tracebacks', True)

    startup.set_config('global', 'engine.autoreload_on', True)




    hostname = None
    server_default = '127.0.0.1'

    if not server:
        hostname = Config.get_value("install", "hostname") 
        if hostname == 'localhost':
            # swap it to IP to suppress CherryPy Warning
            hostname = server_default
        if hostname:
            # special host name for IIS which can't load balance across many
            # ports with the same service
            hostname = hostname.replace("{port}", str(port))
            server = hostname
        else:
            server = server_default
       
    startup.set_config('global', 'server.socket_host', server)

    startup.execute()
示例#4
0
def startup(port, server=""):

    from tactic.startup import FirstRunInit
    cmd = FirstRunInit()
    cmd.execute()

    log_dir = "%s/log" % Environment.get_tmp_dir()
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)

    try:
        file = open("%s/pid.%s" % (log_dir, port), "w")
        pid = os.getpid()
        file.write(str(pid))
        file.close()
    except IOError as e:
        if e.errno == 13:
            print
            print("Permission error opening the file [%s/pid.%s]." %
                  (log_dir, port))
            print
            if os.name == 'nt':
                print("You may need to run this shell as the Administrator.")
            else:
                print(
                    "The file should be owned by the same user that runs this startup_dev.py process."
                )
            sys.exit(2)

    if os.name != 'nt' and os.getuid() == 0:
        print
        print(
            "You should not run this as root. Run it as the Web server process's user. e.g. apache"
        )
        print
        sys.exit(0)

    import cherrypy
    cherrypy_major_version = int(cherrypy.__version__.split('.')[0])
    if cherrypy_major_version >= 3:
        from pyasm.web.cherrypy30_startup import CherryPyStartup
        startup = CherryPyStartup(port)

        startup.set_config('global', 'server.socket_port', port)

        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', 50)
        #startup.set_config('global', 'server.socket_host', server)

        startup.set_config('global', 'log.screen', False)

        startup.set_config('global', 'request.show_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

        startup.set_config('global', 'engine.autoreload_on', True)
        """ 
        access_log = cherrypy.log.access_log
        for handler in tuple(access_log.handlers):
            access_log.removeHandler(handler)
        cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        """

    else:
        from pyasm.web.cherrypy_startup import CherryPyStartup
        startup = CherryPyStartup(port)
        startup.set_config('global', 'server.environment', 'development')
        startup.set_config('global', 'server.socket_port', port)

        startup.set_config('global', 'server.log_to_screen', True)
        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', 100)
        #startup.set_config('global', 'server.socket_host', server)

        startup.set_config('global', 'server.log_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

    hostname = None
    server_default = '127.0.0.1'

    if not server:
        hostname = Config.get_value("install", "hostname")
        if hostname == 'localhost':
            # swap it to IP to suppress CherryPy Warning
            hostname = server_default
        if hostname:
            # special host name for IIS which can't load balance across many
            # ports with the same service
            hostname = hostname.replace("{port}", str(port))
            server = hostname
        else:
            server = server_default

    startup.set_config('global', 'server.socket_host', server)

    startup.execute()
示例#5
0
def startup(port, server=""):

    from tactic.startup import FirstRunInit
    cmd = FirstRunInit()
    cmd.execute()

    log_dir = "%s/log" % Environment.get_tmp_dir()
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)

   
    try:
        file = open("%s/pid.%s" % (log_dir,port), "w")
        pid = os.getpid()
        file.write(str(pid))
        file.close()
    except IOError as e:
        if e.errno == 13:
            print
            print("Permission error opening the file [%s/pid.%s]." % (log_dir,port))
            print
            if os.name=='nt':
                print("You may need to run this shell as the Administrator.")
            else:
                print("The file should be owned by the same user that runs this startup_dev.py process.")
            sys.exit(2)



    if os.name != 'nt' and os.getuid() == 0:
        print 
        print("You should not run this as root. Run it as the Web server process's user. e.g. apache")
        print 
        sys.exit(0)

    import cherrypy
    cherrypy_major_version = int(cherrypy.__version__.split('.')[0])
    if cherrypy_major_version >= 3:
        from pyasm.web.cherrypy30_startup import CherryPyStartup
        startup = CherryPyStartup(port)

        startup.set_config('global', 'server.socket_port', port)
        
        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', 50)
        #startup.set_config('global', 'server.socket_host', server)

        startup.set_config('global', 'log.screen', False)

        startup.set_config('global', 'request.show_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

        startup.set_config('global', 'engine.autoreload_on', True)


        """ 
        access_log = cherrypy.log.access_log
        for handler in tuple(access_log.handlers):
            access_log.removeHandler(handler)
        cherrypy.log.error_log.propagate = False
        cherrypy.log.access_log.propagate = False
        """





    else:
        from pyasm.web.cherrypy_startup import CherryPyStartup
        startup = CherryPyStartup(port)
        startup.set_config('global', 'server.environment', 'development')
        startup.set_config('global', 'server.socket_port', port)
        
        startup.set_config('global', 'server.log_to_screen', True)
        startup.set_config('global', 'server.socket_queue_size', 100)
        startup.set_config('global', 'server.thread_pool', 100)
        #startup.set_config('global', 'server.socket_host', server)

        startup.set_config('global', 'server.log_tracebacks', True)
        startup.set_config('global', 'server.log_unhandled_tracebacks', True)

    hostname = None
    server_default = '127.0.0.1'
    
    if not server:
        hostname = Config.get_value("install", "hostname") 
        if hostname == 'localhost':
            # swap it to IP to suppress CherryPy Warning
            hostname = server_default
        if hostname:
            # special host name for IIS which can't load balance across many
            # ports with the same service
            hostname = hostname.replace("{port}", str(port))
            server = hostname
        else:
            server = server_default
       
    startup.set_config('global', 'server.socket_host', server)



    startup.execute()