forked from shaba/openuds
Improvements
* Added taskmanager foreground exec method * catch checkState exceptions (not expected anyway) and mark pubs as errored
This commit is contained in:
parent
69c4fd6325
commit
f888d1da61
@ -192,7 +192,10 @@ class PublicationFinishChecker(DelayedTask):
|
||||
else:
|
||||
publicationInstance = publication.getInstance()
|
||||
logger.debug("publication instance class: %s", publicationInstance.__class__)
|
||||
state = publicationInstance.checkState()
|
||||
try:
|
||||
state = publicationInstance.checkState()
|
||||
except Exception:
|
||||
state = State.ERROR
|
||||
PublicationFinishChecker.checkAndUpdateState(publication, publicationInstance, state)
|
||||
except Exception as e:
|
||||
logger.debug('Deployed service not found (erased from database) %s : %s', e.__class__, e)
|
||||
|
@ -127,6 +127,7 @@ class TaskManager:
|
||||
time.sleep(0.5) # Wait a bit before next delayed task runner is started
|
||||
|
||||
signal.signal(signal.SIGTERM, TaskManager.sigTerm)
|
||||
signal.signal(signal.SIGINT, TaskManager.sigTerm)
|
||||
|
||||
# Debugging stuff
|
||||
# import guppy
|
||||
|
@ -102,6 +102,13 @@ class Command(BaseCommand):
|
||||
default=False,
|
||||
help='Stop any running daemon'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--foreground',
|
||||
action='store_true',
|
||||
dest='foreground',
|
||||
default=False,
|
||||
help='Stop any running daemon'
|
||||
)
|
||||
|
||||
def handle(self, *args, **options) -> None:
|
||||
logger.info("Running task manager command")
|
||||
@ -110,8 +117,9 @@ class Command(BaseCommand):
|
||||
|
||||
start = options.get('start', False)
|
||||
stop = options.get('stop', False)
|
||||
foreground = options.get('foreground', False)
|
||||
|
||||
logger.debug('Start: %s, Stop: %s', start, stop)
|
||||
logger.debug('Start: %s, Stop: %s, Foreground: %s', start, stop, foreground)
|
||||
|
||||
pid: int = 0
|
||||
try:
|
||||
@ -131,10 +139,12 @@ class Command(BaseCommand):
|
||||
|
||||
if start:
|
||||
logger.info('Starting task manager.')
|
||||
become_daemon(settings.BASE_DIR, settings.LOGDIR + '/taskManagerStdout.log', settings.LOGDIR + '/taskManagerStderr.log')
|
||||
pid = str(os.getpid())
|
||||
|
||||
open(getPidFile(), 'w+').write('{}\n'.format(pid))
|
||||
if not foreground:
|
||||
become_daemon(settings.BASE_DIR, settings.LOGDIR + '/taskManagerStdout.log', settings.LOGDIR + '/taskManagerStderr.log')
|
||||
pid = os.getpid()
|
||||
|
||||
open(getPidFile(), 'w+').write('{}\n'.format(pid))
|
||||
|
||||
manager = taskManager()()
|
||||
manager.run()
|
||||
|
@ -72,7 +72,6 @@ class ServicePoolPublication(UUIDModel):
|
||||
"""
|
||||
A deployed service publication keep track of data needed by services that needs "preparation". (i.e. Virtual machine --> base machine --> children of base machines)
|
||||
"""
|
||||
# pylint: disable=model-missing-unicode
|
||||
deployed_service: ServicePool = models.ForeignKey(ServicePool, on_delete=models.CASCADE, related_name='publications')
|
||||
publish_date = models.DateTimeField(db_index=True)
|
||||
# data_type = models.CharField(max_length=128) # The data type is specified by the service itself
|
||||
|
Loading…
Reference in New Issue
Block a user