Commit b80d6f51 authored by Thomas Phil's avatar Thomas Phil

Fixed setup scripts

parent 2d537169
from cleo import Application
from cleo.inputs.argv_input import ArgvInput
import strongr.core
import logging.config
from strongr.core.domain.configdomain import ConfigDomain
# Use CLEO ArgvInput to extract some parameters
# this dependency gets injected into
# application.run(..) as well
argvInputs = ArgvInput()
# env is used for loading the right config environment
env = "develop"
if argvInputs.has_parameter_option('env'):
env = argvInputs.get_parameter_option('env')
core = strongr.core.Core
ConfigDomain.configService().getCommandBus().handle(ConfigDomain.commandFactory().newLoadConfig(env))
logging.config.dictConfig(core.config().logger.as_dict())
from strongr.cli import DeploySingleCommand, ListDeployedVmsCommand,\
DeployManyCommand,\
AddJobCommand, GetFinishedJobsCommand,\
RunResourceManager, PrintConfig,\
IsValidUserCommand, RunRestServerCommand,\
RunWorkerCommand, DestroySingleCommand,\
DestroyManyCommand, EnsureMinAmountOfNodesCommand, \
MakeDbCommand, RunTestsCommand, TestCommand, CleanupCommand,\
GetJobStdOut
application = Application()
application.add(DeploySingleCommand())
application.add(ListDeployedVmsCommand())
application.add(DeployManyCommand())
application.add(AddJobCommand())
application.add(GetFinishedJobsCommand())
application.add(RunResourceManager())
application.add(PrintConfig())
application.add(IsValidUserCommand())
application.add(RunRestServerCommand())
application.add(RunWorkerCommand())
application.add(DestroySingleCommand())
application.add(DestroyManyCommand())
application.add(EnsureMinAmountOfNodesCommand())
application.add(MakeDbCommand())
application.add(RunTestsCommand())
application.add(TestCommand())
application.add(CleanupCommand())
application.add(GetJobStdOut())
if __name__ == '__main__':
application.run(input_=argvInputs)
from setuptools import setup
from setuptools import setup, find_packages
setup(
name='strongr',
......@@ -8,5 +8,7 @@ setup(
author_email='thomas@tphil.nl',
packages=find_packages(), #same as name
install_requires=[], #external packages as dependencies
scripts=[]
scripts=[
'bin/strongr'
]
)
......@@ -39,13 +39,13 @@ class RunResourceManager(Command):
for command in remotable_commands[domain]:
strongr.core.Core.command_router().enable_route_for_command(celery, '{}.{}'.format(domain, command))
else:
self.info('Celery not configured, skipping')
self.warning('Celery not configured, skipping')
schedule.every(1).seconds.do(command_bus.handle, run_enqueued_jobs_command)
schedule.every(5).seconds.do(command_bus.handle, check_scaling_command)
schedule.every(10).seconds.do(command_bus.handle, log_stats)
schedule.every(1).minutes.do(command_bus.handle, cleanup_nodes)
schedule.every(30).minutes.do(command_bus.handle, cleanup_jobs)
#schedule.every(30).minutes.do(command_bus.handle, cleanup_jobs)
while True:
schedule.run_pending()
......
......@@ -15,6 +15,7 @@ import tempfile
import threading
import strongr.core
import time
class RunJobHandler(AbstractRunJobHandler):
def __call__(self, command):
......@@ -47,6 +48,8 @@ class RunJobHandler(AbstractRunJobHandler):
if ret_code != 0:
raise Exception('Something went wrong while initializing docker image: {}'.format(cmd))
time.sleep(1)
tmpfile = tempfile.mkstemp()[1]
fh = open(tmpfile, 'w')
fh.write("\n".join(command.script))
......@@ -64,6 +67,7 @@ class RunJobHandler(AbstractRunJobHandler):
os.remove(tmpfile)
time.sleep(1)
cmd = 'docker stop {}'.format(command.job_id)
ret_code = subprocess.call(cmd, shell=True)
......@@ -71,6 +75,7 @@ class RunJobHandler(AbstractRunJobHandler):
if ret_code != 0:
raise Exception('Something went wrong while stopping docker image: {}'.format(cmd))
time.sleep(1)
job_finished_event = inter_domain_event_factory.newJobFinishedEvent(command.job_id, stdout, 0)
inter_domain_events_publisher.publish(job_finished_event)
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