97 request.setHeader('Expires', generateDateTime(mktime(expires.timetuple()))) |
97 request.setHeader('Expires', generateDateTime(mktime(expires.timetuple()))) |
98 return File.render(self, request) |
98 return File.render(self, request) |
99 |
99 |
100 |
100 |
101 class CubicWebRootResource(resource.Resource): |
101 class CubicWebRootResource(resource.Resource): |
102 def __init__(self, config): |
102 def __init__(self, config, vreg=None): |
103 self.config = config |
103 self.config = config |
104 # instantiate publisher here and not in init_publisher to get some |
104 # instantiate publisher here and not in init_publisher to get some |
105 # checks done before daemonization (eg versions consistency) |
105 # checks done before daemonization (eg versions consistency) |
106 self.appli = CubicWebPublisher(config) |
106 self.appli = CubicWebPublisher(config, vreg=vreg) |
107 self.base_url = config['base-url'] |
107 self.base_url = config['base-url'] |
108 self.https_url = config['https-url'] |
108 self.https_url = config['https-url'] |
109 self.children = {} |
109 self.children = {} |
110 self.static_directories = set(('data%s' % config.instance_md5_version(), |
110 self.static_directories = set(('data%s' % config.instance_md5_version(), |
111 'data', 'static', 'fckeditor')) |
111 'data', 'static', 'fckeditor')) |
385 from logging import getLogger |
385 from logging import getLogger |
386 from cubicweb import set_log_methods |
386 from cubicweb import set_log_methods |
387 LOGGER = getLogger('cubicweb.twisted') |
387 LOGGER = getLogger('cubicweb.twisted') |
388 set_log_methods(CubicWebRootResource, LOGGER) |
388 set_log_methods(CubicWebRootResource, LOGGER) |
389 |
389 |
390 def run(config): |
390 def run(config, vreg=None, debug=None): |
|
391 if debug is not None: |
|
392 config.debugmode = debug |
391 # create the site |
393 # create the site |
392 root_resource = CubicWebRootResource(config) |
394 root_resource = CubicWebRootResource(config, vreg=vreg) |
393 website = server.Site(root_resource) |
395 website = server.Site(root_resource) |
394 # serve it via standard HTTP on port set in the configuration |
396 # serve it via standard HTTP on port set in the configuration |
395 port = config['port'] or 8080 |
397 port = config['port'] or 8080 |
396 reactor.listenTCP(port, website) |
398 reactor.listenTCP(port, website) |
397 logger = getLogger('cubicweb.twisted') |
399 logger = getLogger('cubicweb.twisted') |
398 if not config.debugmode: |
400 if not config.debugmode: |
399 if sys.platform == 'win32': |
401 if sys.platform == 'win32': |
400 raise ConfigurationError("Under windows, you must use the service management " |
402 raise ConfigurationError("Under windows, you must use the service management " |
401 "commands (e.g : 'net start my_instance)'") |
403 "commands (e.g : 'net start my_instance)'") |
402 print 'instance starting in the background' |
404 logger.info('instance started in the background on %s', root_resource.base_url) |
403 if daemonize(config['pid-file']): |
405 if daemonize(config['pid-file']): |
404 return # child process |
406 return # child process |
405 root_resource.init_publisher() # before changing uid |
407 root_resource.init_publisher() # before changing uid |
406 if config['uid'] is not None: |
408 if config['uid'] is not None: |
407 try: |
409 try: |