{"action":"opened","issue":{"url":"https://api.github.com/repos/gem/oq-engine/issues/2201","repository_url":"https://api.github.com/repos/gem/oq-engine","labels_url":"https://api.github.com/repos/gem/oq-engine/issues/2201/labels{/name}","comments_url":"https://api.github.com/repos/gem/oq-engine/issues/2201/comments","events_url":"https://api.github.com/repos/gem/oq-engine/issues/2201/events","html_url":"https://github.com/gem/oq-engine/issues/2201","id":173961390,"number":2201,"title":"Improve the dbserver behaviour when CTRL-C is fired","user":{"login":"daniviga","id":1818657,"avatar_url":"https://avatars.githubusercontent.com/u/1818657?v=3","gravatar_id":"","url":"https://api.github.com/users/daniviga","html_url":"https://github.com/daniviga","followers_url":"https://api.github.com/users/daniviga/followers","following_url":"https://api.github.com/users/daniviga/following{/other_user}","gists_url":"https://api.github.com/users/daniviga/gists{/gist_id}","starred_url":"https://api.github.com/users/daniviga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniviga/subscriptions","organizations_url":"https://api.github.com/users/daniviga/orgs","repos_url":"https://api.github.com/users/daniviga/repos","events_url":"https://api.github.com/users/daniviga/events{/privacy}","received_events_url":"https://api.github.com/users/daniviga/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/gem/oq-engine/labels/bug","name":"bug","color":"ed2b6c"},{"url":"https://api.github.com/repos/gem/oq-engine/labels/enhancement","name":"enhancement","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"daniviga","id":1818657,"avatar_url":"https://avatars.githubusercontent.com/u/1818657?v=3","gravatar_id":"","url":"https://api.github.com/users/daniviga","html_url":"https://github.com/daniviga","followers_url":"https://api.github.com/users/daniviga/followers","following_url":"https://api.github.com/users/daniviga/following{/other_user}","gists_url":"https://api.github.com/users/daniviga/gists{/gist_id}","starred_url":"https://api.github.com/users/daniviga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniviga/subscriptions","organizations_url":"https://api.github.com/users/daniviga/orgs","repos_url":"https://api.github.com/users/daniviga/repos","events_url":"https://api.github.com/users/daniviga/events{/privacy}","received_events_url":"https://api.github.com/users/daniviga/received_events","type":"User","site_admin":false},"assignees":[{"login":"daniviga","id":1818657,"avatar_url":"https://avatars.githubusercontent.com/u/1818657?v=3","gravatar_id":"","url":"https://api.github.com/users/daniviga","html_url":"https://github.com/daniviga","followers_url":"https://api.github.com/users/daniviga/followers","following_url":"https://api.github.com/users/daniviga/following{/other_user}","gists_url":"https://api.github.com/users/daniviga/gists{/gist_id}","starred_url":"https://api.github.com/users/daniviga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniviga/subscriptions","organizations_url":"https://api.github.com/users/daniviga/orgs","repos_url":"https://api.github.com/users/daniviga/repos","events_url":"https://api.github.com/users/daniviga/events{/privacy}","received_events_url":"https://api.github.com/users/daniviga/received_events","type":"User","site_admin":false},{"login":"micheles","id":2463856,"avatar_url":"https://avatars.githubusercontent.com/u/2463856?v=3","gravatar_id":"","url":"https://api.github.com/users/micheles","html_url":"https://github.com/micheles","followers_url":"https://api.github.com/users/micheles/followers","following_url":"https://api.github.com/users/micheles/following{/other_user}","gists_url":"https://api.github.com/users/micheles/gists{/gist_id}","starred_url":"https://api.github.com/users/micheles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheles/subscriptions","organizations_url":"https://api.github.com/users/micheles/orgs","repos_url":"https://api.github.com/users/micheles/repos","events_url":"https://api.github.com/users/micheles/events{/privacy}","received_events_url":"https://api.github.com/users/micheles/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2016-08-30T08:40:37Z","updated_at":"2016-08-30T08:40:37Z","closed_at":null,"body":"When the _dbserver_ process is started manually (usually by `oq dbserver start`) it cannot be stopped with `ctrl-c`. If `ctrl-c` is pressed by mistake the process does not exit even if `oq dbserver stop` says \"dbserver already stopped\" and the _dbserver_ process can be stopped only using kill; this is dangerous because even if the process stays alive it does not accept any new connection and another _dbserver_ process is spawned if a new calculation is fired.\r\n\r\nA similar issue appears when `oq webui start` is used: when `ctrl-c` is fired to stop the _webui server_ the dbserver stays in background but it cannot be stopped by `oq dbserver stop` (it returns \"dbserver already stopped\") and must be killed instead. As said before if a new calculation is started a new dbserver process is created:\r\n\r\n```bash\r\n$ oq webui start\r\n$ ps a | grep dbserver\r\n29087 pts/9    Sl+    0:01 /home/daniele/py2/bin/python2 -m openquake.server.dbserver\r\n\r\n# CTRL-C #\r\n  File \"/home/daniele/py2/bin/oq\", line 9, in <module>\r\n    load_entry_point('openquake.engine', 'console_scripts', 'oq')()\r\n  File \"/home/daniele/GIT/gem/openquake/oq-engine/openquake/commands/__main__.py\", line 44, in oq\r\n    parser.callfunc()\r\n  File \"/home/daniele/GIT/gem/openquake/oq-hazardlib/openquake/baselib/sap.py\", line 184, in callfunc\r\n    return self.func(**vars(namespace))\r\n  File \"/home/daniele/GIT/gem/openquake/oq-hazardlib/openquake/baselib/sap.py\", line 239, in main\r\n    return func(**kw)\r\n  File \"/home/daniele/GIT/gem/openquake/oq-engine/openquake/commands/webui.py\", line 47, in webui\r\n    rundjango('runserver', hostport)\r\n  File \"/home/daniele/GIT/gem/openquake/oq-engine/openquake/commands/webui.py\", line 30, in rundjango\r\n    subprocess.call(args)\r\n  File \"/usr/lib64/python2.7/subprocess.py\", line 523, in call\r\n    return Popen(*popenargs, **kwargs).wait()\r\n  File \"/usr/lib64/python2.7/subprocess.py\", line 1392, in wait\r\n    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)\r\n  File \"/usr/lib64/python2.7/subprocess.py\", line 476, in _eintr_retry_call\r\n    return func(*args)\r\nKeyboardInterrupt\r\n\r\n$ ps a | grep dbserver\r\n29087 pts/9    Sl     0:01 /home/daniele/py2/bin/python2 -m openquake.server.dbserver\r\n$ oq dbserver stop\r\ndbserver already stopped\r\n$ oq webui start # (or oq engine --run <...>)\r\n$ps a | grep dbserver\r\n29087 pts/9    Sl     0:01 /home/daniele/py2/bin/python2 -m openquake.server.dbserver\r\n29341 pts/9    Sl     0:00 /home/daniele/py2/bin/python2 -m openquake.server.dbserver\r\n```\r\n\r\n\r\n"}}
{"actor":{"display_login":"daniviga"}}