Commit d6f04862 authored by Jerico Moeyersons 's avatar Jerico Moeyersons 🏘
Browse files

Bugfixes + enable off command

parent 85a02fce
*.log
**/__pycache__/
\ No newline at end of file
This diff is collapsed.
......@@ -61,8 +61,9 @@ def shutdown():
Returns:
string -- notify that server is shutting down.
"""
shut_down_server()
return 'Server shutting down...'
return kernel.shutdown_workers()
# shut_down_server()
# return 'Server shutting down...'
def main():
app.run(host='0.0.0.0', port=80)
......
......@@ -12,7 +12,7 @@ import exceptions
WORKER_URL = 'http://worker-'
DEFAULT_NETWORK = 'mandelbrot-creator_mandelbrot'
WORKER_IMAGE_NAME = 'worker'
WORKER_IMAGE_NAME = 'gitlab.ilabt.imec.be:4567/jfmoeyer/mandelbrot-creator:worker'
class Kernel(object):
......@@ -39,7 +39,7 @@ class Kernel(object):
# Try to start a container with the process
try:
# Start a new container with the plugin process.
container_name = WORKER_IMAGE_NAME + "-" + str(i)
container_name = "worker-" + str(i)
container = self.docker_client.containers.run(
image=WORKER_IMAGE_NAME,
detach=True,
......@@ -122,6 +122,14 @@ class Kernel(object):
message = "Another job is running, please try again later..."
return (message, code)
def shutdown_workers(self):
for worker in self.workers:
worker.stop()
worker.remove()
message = "All workers stopped successfully..."
code = http.HTTPStatus.OK.value
return (message, code)
def __set_next_worker(self):
if self.next_worker == len(self.workers)-1:
self.next_worker = 0
......
......@@ -57,7 +57,7 @@ def off():
click.echo('Mandelbrot-creator shut down')
###################
# Plugins command #
# Workers command #
###################
@cli.command()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment