Exemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--colors", help="add colors to shell", nargs=1)
    parser.add_argument("-f", "--file", help="add configuration file", nargs=1)
    args = parser.parse_args()
    fd = None
    if (args.file != None):
        fd = check_fileExistance(args.file[0])
    if (fd is not None):
        global progs
        progs = ProgramList(fd)
        progs.launch()

    print "BEGIN TASKMASTER"
    logger.log("BEGIN TASKMASTER")
    signal.signal(signal.SIGINT, signal_handler)

    if os.path.exists(historyPath):
        readline.read_history_file(historyPath)

    global progs_lock
    progs_lock = threading.Lock()

    # launch a thread to test progs
    t = threading.Thread(target=thread_check_progs)
    t.daemon = True
    t.start()
    shell(progs, args.colors)
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--colors", help="add colors to shell", nargs=1)
    parser.add_argument("-f", "--file", help="add configuration file", nargs=1)
    args = parser.parse_args()
    fd = None
    if (args.file != None):
        fd = check_fileExistance(args.file[0])
    if (fd is not None):
        global progs
        progs = ProgramList(fd)
        progs.launch()

    print "BEGIN TASKMASTER"
    logger.log("BEGIN TASKMASTER")
    signal.signal(signal.SIGINT, signal_handler)

    if os.path.exists(historyPath):
        readline.read_history_file(historyPath)

    global progs_lock
    progs_lock = threading.Lock()

    # launch a thread to test progs
    t = threading.Thread(target = thread_check_progs)
    t.daemon = True
    t.start()
    shell(progs, args.colors)
Exemplo n.º 3
0
def loadNewConfig(progs, file_name):
	logger.log("loading file")
	print "loading file"
	if os.access(file_name, os.R_OK):
		fd = open(file_name, 'r')
	else:
		print("File can't be opened")
		logger.log("File can't be opened")
		return
	if progs is not None:
		progs.kill_all()
	progs = ProgramList(fd)
	progs.launch()
	return progs
Exemplo n.º 4
0
def reloadConfig(old_progs):
	if old_progs is None:
		logger.log("no config file loaded")
		print "NO CONFIG FILE LOADED"
		return None

	logger.log("TaskMaster reloaded")
	print "TaskMaster reloaded"
	new_progs = ProgramList(old_progs.fd)
	for oprog in old_progs.lst:
		for nprog in new_progs.lst:
			# only program which we care about processes should be keep
			if oprog.name == nprog.name:
				oprog.keep_running_process(nprog)
				break

	# now all the progs are in new_progs
	new_progs.reload()
	return new_progs