def main(cmd, dbhostport=None, foreground=False, *, loglevel='INFO'): """ start/stop/restart the database server, or return its status """ if config.dbserver.multi_user and getpass.getuser() != 'openquake': sys.exit('oq dbserver only works in single user mode') status = dbs.get_status() if cmd == 'status': print('dbserver ' + status) elif cmd == 'stop': if status == 'running': pid = logs.dbcmd('getpid') os.kill(pid, signal.SIGINT) # this is trapped by the DbServer else: print('dbserver already stopped') elif cmd == 'start': if status == 'not-running': dbs.run_server(dbhostport, loglevel, foreground) else: print('dbserver already running')
def dbserver(cmd): """ start/stop/restart the database server, or return its status """ if valid.boolean(config.get('dbserver', 'multi_user')): sys.exit('oq dbserver only works in single user mode') status = dbs.get_status() if cmd == 'status': print('dbserver ' + status) elif cmd == 'stop': if status == 'running': logs.dbcmd('stop') print('dbserver stopped') else: print('dbserver already stopped') elif cmd == 'start': if status == 'not-running': dbs.run_server() else: print('dbserver already running') elif cmd == 'restart': if status == 'running': logs.dbcmd('stop') print('dbserver stopped') dbs.run_server()
def dbserver(cmd, dbhostport=None, dbpath=os.path.expanduser(config.dbserver.file), foreground=False): """ start/stop/restart the database server, or return its status """ if config.dbserver.multi_user and getpass.getuser() != 'openquake': sys.exit('oq dbserver only works in single user mode') status = dbs.get_status() if cmd == 'status': print('dbserver ' + status) elif cmd == 'stop': if status == 'running': pid = logs.dbcmd('getpid') os.kill(pid, signal.SIGINT) # this is trapped by the DbServer else: print('dbserver already stopped') elif cmd == 'start': if status == 'not-running': dbs.run_server(dbpath, dbhostport) else: print('dbserver already running') elif cmd == 'restart': if status == 'running': pid = logs.dbcmd('getpid') os.kill(pid, signal.SIGINT) dbs.run_server(dbpath, dbhostport)
def dbserver(cmd, dbhostport=None, dbpath=None): """ start/stop/restart the database server, or return its status """ if valid.boolean(config.get('dbserver', 'multi_user')): sys.exit('oq dbserver only works in single user mode') status = dbs.get_status() if cmd == 'status': print('dbserver ' + status) elif cmd == 'stop': if status == 'running': logs.dbcmd('stop') print('dbserver stopped') else: print('dbserver already stopped') elif cmd == 'start': if status == 'not-running': dbs.run_server(dbhostport, dbpath) else: print('dbserver already running') elif cmd == 'restart': if status == 'running': logs.dbcmd('stop') print('dbserver stopped') dbs.run_server(dbhostport, dbpath)