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(): ...@@ -61,8 +61,9 @@ def shutdown():
Returns: Returns:
string -- notify that server is shutting down. string -- notify that server is shutting down.
""" """
shut_down_server() return kernel.shutdown_workers()
return 'Server shutting down...' # shut_down_server()
# return 'Server shutting down...'
def main(): def main():
app.run(host='0.0.0.0', port=80) app.run(host='0.0.0.0', port=80)
......
...@@ -12,7 +12,7 @@ import exceptions ...@@ -12,7 +12,7 @@ import exceptions
WORKER_URL = 'http://worker-' WORKER_URL = 'http://worker-'
DEFAULT_NETWORK = 'mandelbrot-creator_mandelbrot' DEFAULT_NETWORK = 'mandelbrot-creator_mandelbrot'
WORKER_IMAGE_NAME = 'worker' WORKER_IMAGE_NAME = 'gitlab.ilabt.imec.be:4567/jfmoeyer/mandelbrot-creator:worker'
class Kernel(object): class Kernel(object):
...@@ -39,7 +39,7 @@ class Kernel(object): ...@@ -39,7 +39,7 @@ class Kernel(object):
# Try to start a container with the process # Try to start a container with the process
try: try:
# Start a new container with the plugin process. # 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( container = self.docker_client.containers.run(
image=WORKER_IMAGE_NAME, image=WORKER_IMAGE_NAME,
detach=True, detach=True,
...@@ -122,6 +122,14 @@ class Kernel(object): ...@@ -122,6 +122,14 @@ class Kernel(object):
message = "Another job is running, please try again later..." message = "Another job is running, please try again later..."
return (message, code) 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): def __set_next_worker(self):
if self.next_worker == len(self.workers)-1: if self.next_worker == len(self.workers)-1:
self.next_worker = 0 self.next_worker = 0
......
...@@ -57,7 +57,7 @@ def off(): ...@@ -57,7 +57,7 @@ def off():
click.echo('Mandelbrot-creator shut down') click.echo('Mandelbrot-creator shut down')
################### ###################
# Plugins command # # Workers command #
################### ###################
@cli.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