Skip to content

Commit

Permalink
Merge pull request #7 from ITISFoundation/webserver_earlier
Browse files Browse the repository at this point in the history
Start webserver earlier
  • Loading branch information
wvangeit authored Jul 3, 2024
2 parents e7bbcd1 + c57287b commit 5bba156
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.1
current_version = 0.1.2
commit = False
message = service version: {current_version} → {new_version}
tag = False
Expand Down
2 changes: 1 addition & 1 deletion .osparc/osparc-meta-parallelrunner/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Parallel Runner
description: "ParallelRunnerService"
key: simcore/services/dynamic/osparc-meta-parallelrunner
version: 0.1.1
version: 0.1.2
integration-version: 2.0.0
type: dynamic
authors:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SHELL = /bin/sh
MAKEFLAGS += -j2

export DOCKER_IMAGE_NAME ?= osparc-meta-parallelrunner
export DOCKER_IMAGE_TAG ?= 0.1.1
export DOCKER_IMAGE_TAG ?= 0.1.2

export MASTER_AWS_REGISTRY ?= registry.osparc-master-zmt.click
export MASTER_REGISTRY ?= registry.osparc-master.speag.com
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
osparc-meta-parallelrunner:
image: simcore/services/dynamic/osparc-meta-parallelrunner:0.1.1
image: simcore/services/dynamic/osparc-meta-parallelrunner:0.1.2
ports:
- "8888:8888"
environment:
Expand Down
28 changes: 16 additions & 12 deletions docker_scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ def main():
settings = MainSettings()
config_path = settings.input_path / INPUT_CONF_KEY / "parallelrunner.json"

waiter = 0
while not config_path.exists():
if waiter % 10 == 0:
logger.info("Waiting for parallelrunner.json to exist ...")
time.sleep(settings.file_polling_interval)
waiter += 1

settings = settings.parse_file(config_path)
logging.info(f"Received the following settings: {settings}")

http_dir_path = pl.Path(__file__).parent / "http"

class HTTPHandler(http.server.SimpleHTTPRequestHandler):
Expand All @@ -44,18 +34,32 @@ def __init__(self, *args, **kwargs):
*args, **kwargs, directory=http_dir_path.resolve()
)

maprunner = parallelrunner.ParallelRunner(**settings.dict())

try:
logger.info(
f"Starting http server at port {HTTP_PORT} and serving path {http_dir_path}"
)
with socketserver.TCPServer(("", HTTP_PORT), HTTPHandler) as httpd:
# First start the empty web server
httpd_thread = threading.Thread(target=httpd.serve_forever)
httpd_thread.start()

# Now start the real parallel runner
waiter = 0
while not config_path.exists():
if waiter % 10 == 0:
logger.info("Waiting for parallelrunner.json to exist ...")
time.sleep(settings.file_polling_interval)
waiter += 1

settings = settings.parse_file(config_path)
logging.info(f"Received the following settings: {settings}")

maprunner = parallelrunner.ParallelRunner(**settings.dict())

maprunner.setup()
maprunner.start()
maprunner.teardown()

httpd.shutdown()
except Exception as err: # pylint: disable=broad-except
logger.error(f"{err} . Stopping %s", exc_info=True)
Expand Down

0 comments on commit 5bba156

Please sign in to comment.