Launchpad automatic translations update.
[odoo/odoo.git] / openerp-server
index 60eccd7..71a52d5 100755 (executable)
@@ -89,15 +89,17 @@ def setup_pid_file():
 def preload_registry(dbname):
     """ Preload a registry, and start the cron."""
     try:
-        db, pool = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False)
-        pool.get('ir.cron').restart(db.dbname)
+        db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False)
+
+        # jobs will start to be processed later, when openerp.cron.start_master_thread() is called by openerp.service.start_services()
+        registry.schedule_cron_jobs()
     except Exception:
         logging.exception('Failed to initialize database `%s`.', dbname)
 
 def run_test_file(dbname, test_file):
     """ Preload a registry, possibly run a test file, and start the cron."""
     try:
-        db, pool = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False)
+        db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'], pooljobs=False)
         cr = db.cursor()
         logger = logging.getLogger('server')
         logger.info('loading test file %s', test_file)
@@ -177,9 +179,12 @@ def dumpstacks(sig, frame):
 def setup_signal_handlers():
     """ Register the signal handler defined above. """
     SIGNALS = map(lambda x: getattr(signal, "SIG%s" % x), "INT TERM".split())
-    map(lambda sig: signal.signal(sig, signal_handler), SIGNALS)
     if os.name == 'posix':
+        map(lambda sig: signal.signal(sig, signal_handler), SIGNALS)
         signal.signal(signal.SIGQUIT, dumpstacks)
+    elif os.name == 'nt':
+        import win32api
+        win32api.SetConsoleCtrlHandler(lambda sig: signal_handler(sig, None), 1)
 
 def quit_on_signals():
     """ Wait for one or two signals then shutdown the server.
@@ -189,9 +194,12 @@ def quit_on_signals():
 
     """
     # Wait for a first signal to be handled. (time.sleep will be interrupted
-    # by the signal handler.)
-    while quit_signals_received == 0:
-        time.sleep(60)
+    # by the signal handler.) The try/except is for the win32 case.
+    try:
+        while quit_signals_received == 0:
+            time.sleep(60)
+    except KeyboardInterrupt, e:
+        pass
 
     if config['pidfile']:
         os.unlink(config['pidfile'])
@@ -230,13 +238,6 @@ if __name__ == "__main__":
         # services to be running before loading any registry.
         openerp.service.start_services()
 
-    if config['db_name']:
-        for dbname in config['db_name'].split(','):
-            preload_registry(dbname)
-
-    if config["stop_after_init"]:
-        sys.exit(0)
-
     for m in openerp.conf.server_wide_modules:
         try:
             __import__(m)
@@ -245,7 +246,19 @@ if __name__ == "__main__":
             if info['post_load']:
                 getattr(sys.modules[m], info['post_load'])()
         except Exception:
-            logging.exception('Failed to load server-wide module `%s`', m)
+            msg = ''
+            if m == 'web':
+                msg = """
+The `web` module is provided by the addons found in the `openerp-web` project.
+Maybe you forgot to add those addons in your addons_path configuration."""
+            logging.exception('Failed to load server-wide module `%s`.%s', m, msg)
+
+    if config['db_name']:
+        for dbname in config['db_name'].split(','):
+            preload_registry(dbname)
+
+    if config["stop_after_init"]:
+        sys.exit(0)
 
     setup_pid_file()
     logger = logging.getLogger('server')