summaryrefslogtreecommitdiff
path: root/openerp/cli/server.py
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2014-02-27 17:18:19 +0100
committerAntony Lesuisse <al@openerp.com>2014-02-27 17:18:19 +0100
commit38d1ca1ff2472f4e1d3bc3d5f3454dc7603374a6 (patch)
tree1b2a223afdb1cb27b7d0a19e8bcb7a15ae11219a /openerp/cli/server.py
parent14815d669ff5ae428a74c7b81327667cdbcf44f9 (diff)
parent6df317c54629e5c222e8db511b38ada767ec60af (diff)
[MERGE] trunk
bzr revid: al@openerp.com-20140227161819-p9chmskfifo0rygs
Diffstat (limited to 'openerp/cli/server.py')
-rw-r--r--openerp/cli/server.py50
1 files changed, 10 insertions, 40 deletions
diff --git a/openerp/cli/server.py b/openerp/cli/server.py
index 7041d7a4c3c..42d920da9aa 100644
--- a/openerp/cli/server.py
+++ b/openerp/cli/server.py
@@ -89,29 +89,6 @@ def setup_pid_file():
pidtext = "%d" % (os.getpid())
fd.write(pidtext)
-def preload_registry(dbname):
- """ Preload a registry, and start the cron."""
- try:
- update_module = True if openerp.tools.config['init'] or openerp.tools.config['update'] else False
- registry = openerp.modules.registry.RegistryManager.new(dbname, update_module=update_module)
- except Exception:
- _logger.exception('Failed to initialize database `%s`.', dbname)
- return False
- return registry._assertion_report.failures == 0
-
-def run_test_file(dbname, test_file):
- """ Preload a registry, possibly run a test file, and start the cron."""
- try:
- config = openerp.tools.config
- registry = openerp.modules.registry.RegistryManager.new(dbname, update_module=config['init'] or config['update'])
- cr = registry.db.cursor()
- _logger.info('loading test file %s', test_file)
- openerp.tools.convert_yaml_import(cr, 'base', file(test_file), 'test', {}, 'test', True)
- cr.rollback()
- cr.close()
- except Exception:
- _logger.exception('Failed to initialize database `%s` and run test file `%s`.', dbname, test_file)
-
def export_translation():
config = openerp.tools.config
dbname = config['db_name']
@@ -156,8 +133,7 @@ def main(args):
config = openerp.tools.config
if config["test_file"]:
- run_test_file(config['db_name'], config['test_file'])
- sys.exit(0)
+ config["test_enable"] = True
if config["translate_out"]:
export_translation()
@@ -172,23 +148,17 @@ def main(args):
if config['workers']:
openerp.multi_process = True
- # preload registries, needed for -u --stop_after_init
- rc = 0
+ preload = []
if config['db_name']:
- for dbname in config['db_name'].split(','):
- if not preload_registry(dbname):
- rc += 1
-
- if not config["stop_after_init"]:
- setup_pid_file()
- openerp.service.server.start()
- if config['pidfile']:
- os.unlink(config['pidfile'])
- else:
- sys.exit(rc)
+ preload = config['db_name'].split(',')
- _logger.info('OpenERP server is running, waiting for connections...')
- quit_on_signals()
+ stop = config["stop_after_init"]
+
+ setup_pid_file()
+ rc = openerp.service.server.start(preload=preload, stop=stop)
+ if config['pidfile']:
+ os.unlink(config['pidfile'])
+ sys.exit(rc)
class Server(Command):
def run(self, args):