Skip to content
Snippets Groups Projects
Commit 1fa9cbc5 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

pass job object instead of id.

parent a5687a3f
No related branches found
No related tags found
No related merge requests found
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import docker import docker
import json import json
import os import os
...@@ -13,14 +11,13 @@ class Swarm: ...@@ -13,14 +11,13 @@ class Swarm:
self.docker = docker.from_env() self.docker = docker.from_env()
def init_app(self, app): def init_app(self, app):
engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) pass
self.Session = sessionmaker(bind=engine)
''' '''
' Swarm mode is intendet to run containers which serve a non terminating ' Swarm mode is intendet to run containers which serve a non terminating
' service like a webserver. For processing an occuring job it is necessary ' service like a webserver. For processing an occuring job it is necessary
' to use a one-shot container, which stops after the wrapped job process is ' to use an one-shot container, which stops after the wrapped job process
' completly executed. In order to run these one-shot containers in Swarm ' is completly executed. In order to run these one-shot containers in Swarm
' mode, the following run method is implemented analog to the presented ' mode, the following run method is implemented analog to the presented
' implementation in Alex Ellis' blog post "One-shot containers on Docker ' implementation in Alex Ellis' blog post "One-shot containers on Docker
' Swarm"¹. ' Swarm"¹.
...@@ -28,13 +25,10 @@ class Swarm: ...@@ -28,13 +25,10 @@ class Swarm:
' ¹ https://blog.alexellis.io/containers-on-swarm/ ' ¹ https://blog.alexellis.io/containers-on-swarm/
''' '''
def run(self, job_id): def run(self, job):
''' '''
Input is a job id. Input is a job.
''' '''
from .models import Job
session = self.Session()
job = session.query(Job).filter_by(id=job_id).first()
# Prepare argument values needed for the service creation. # Prepare argument values needed for the service creation.
service_args = json.loads(job.service_args) service_args = json.loads(job.service_args)
_command = (job.service _command = (job.service
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment