def handle(self, *args, **options): sys.stdout.write("Cleaning up UDS\n") GlobalConfig.initialize() # UDSs cache Cache.cleanUp() # Django caches cache.clear() sys.stdout.write("UDS Cleaned UP\n")
def handle(self, *args, **options): sys.stdout.write("Cleaning up UDS\n") GlobalConfig.initialize() sys.stdout.write("Cache...\n") # UDSs cache Cache.cleanUp() # Django caches cache.clear() sys.stdout.write("Releasing schedulers...\n") # Release all Schedulers Scheduler.objects.all().update(owner_server='', state=State.FOR_EXECUTE) sys.stdout.write("UDS Cleaned UP\n")
def handle(self, *args, **options): logger.debug("Handling settings") GlobalConfig.initialize() try: for config in args: logger.debug('Config: {}'.format(config)) first, value = config.split('=') first = first.split('.') if len(first) == 2: mod, name = first else: mod, name = GLOBAL_SECTION, first[0] if Config.update(mod, name, value) is False: # If not exists, try to store value without any special parameters Config.section(mod).value(name, value).get() except Exception: logger.exception('Exception processing {}'.format(args))
def handle(self, *args, **options): logger.info("Running task manager command") GlobalConfig.initialize() start = options['start'] and True or False stop = options['stop'] and True or False pid = None try: pid = int(open(getPidFile(), 'r').readline()) except Exception: pid = None if stop is True and pid is not None: try: logger.info('Stopping task manager. pid: %s', pid) os.kill(pid, signal.SIGTERM) time.sleep(1) # Wait a bit before running new one os.unlink(getPidFile()) except Exception: logger.error( "Could not stop task manager (maybe it's not runing?)") os.unlink(getPidFile()) if start is True: 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)) manager = TaskManager() manager.run() if start is False and stop is False: if pid is not None: sys.stdout.write( "Task manager found running (pid file exists: {0})\n". format(pid)) else: sys.stdout.write( "Task manager not foud (pid file do not exits)\n")
def handle(self, *args, **options): logger.debug("Handling settings") GlobalConfig.initialize() try: for config in options['name_value']: logger.debug('Config: %s', config) first, value = config.split('=') first = first.split('.') if len(first) == 2: mod, name = first else: mod, name = GLOBAL_SECTION, first[0] if Config.update( mod, name, value ) is False: # If not exists, try to store value without any special parameters Config.section(mod).value(name, value).get() except Exception as e: print('The command could not be processed: {}'.format(e)) logger.exception('Exception processing %s', args)
def handle(self, *args, **options): sys.stdout.write("Cleaning up UDS\n") GlobalConfig.initialize() sys.stdout.write("Cache...\n") # UDSs cache Cache.cleanUp() # Django caches cache.clear() sys.stdout.write("Releasing schedulers...\n") # Release all Schedulers Scheduler.objects.all().update(owner_server='', state=State.FOR_EXECUTE) sys.stdout.write("Reseting UDS Theme (setting to html5)...\n") # Reset theme to html5 GlobalConfig.UDS_THEME.set('html5') sys.stdout.write("UDS Cleaned UP\n")
def handle(self, *args, **options): logger.info("Running task manager command") GlobalConfig.initialize() start = options['start'] and True or False stop = options['stop'] and True or False pid = None try: pid = int(file(getPidFile(), 'r').readline()) except Exception: pid = None if stop is True and pid is not None: try: logger.info('Stopping task manager. pid: {0}'.format(pid)) os.kill(pid, signal.SIGTERM) time.sleep(1) # Wait a bit before running new one os.unlink(getPidFile()) except Exception: logger.error("Could not stop task manager (maybe it's not runing?)") os.unlink(getPidFile()) if start is True: logger.info('Starting task manager.') become_daemon(settings.BASE_DIR, settings.LOGDIR + '/taskManagerStdout.log', settings.LOGDIR + '/taskManagerStderr.log') pid = six.text_type(os.getpid()) open(getPidFile(), 'w+').write("%s\n" % pid) manager = TaskManager() manager.run() if start is False and stop is False: if pid is not None: sys.stdout.write("Task manager found running (pid file exists: {0})\n".format(pid)) else: sys.stdout.write("Task manager not foud (pid file do not exits)\n")