Skip to content

Commit

Permalink
Merge pull request #10240 from gem/reset-pending
Browse files Browse the repository at this point in the history
Move `reset_is_running` to be executed whenever the webui is ready
  • Loading branch information
ptormene authored Jan 8, 2025
2 parents 491781d + dfd3b2e commit aa8351e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions openquake/commands/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import webbrowser

from openquake.baselib import config, general
from openquake.server import dbserver, db
from openquake.server import dbserver
from openquake.server.utils import check_webserver_running

commands = ['start']


def runserver(hostport=None, skip_browser=False):
args = [sys.executable, '-m', 'openquake.server.manage', 'runserver']
# the reload functionality of the Django development server interferes
Expand Down Expand Up @@ -56,8 +57,6 @@ def main(cmd, hostport='127.0.0.1:8800', skip_browser: bool = False):
sys.exit('This command must be run by the proper user: '
'see the documentation for details')
dbserver.ensure_on() # start the dbserver in a subprocess
# reset any computation left in the 'executing' state
db.actions.reset_is_running(dbserver.db)
print('Starting, using version %s' % general.engine_version())
runserver(hostport, skip_browser)

Expand Down
9 changes: 9 additions & 0 deletions openquake/server/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import os
from django.apps import AppConfig
from django.conf import settings
from sqlite3 import OperationalError
from openquake.baselib import config
from openquake.server import dbserver, db


class ServerConfig(AppConfig):
Expand All @@ -34,6 +36,13 @@ def ready(self):
# AppConfig classes are defined, you can import them in ready()
import openquake.server.signals # NOQA

# reset any computation left in the 'executing' state
try:
db.actions.reset_is_running(dbserver.db)
except OperationalError:
# in the action "docs" the database does not exist
pass

if settings.APPLICATION_MODE not in settings.APPLICATION_MODES:
raise ValueError(
f'Invalid application mode: "{settings.APPLICATION_MODE}".'
Expand Down

0 comments on commit aa8351e

Please sign in to comment.