diff options
Diffstat (limited to 'steuermann')
-rw-r--r-- | steuermann/run.py | 16 | ||||
-rw-r--r-- | steuermann/run_all.py | 16 | ||||
-rw-r--r-- | steuermann/run_cron.py | 2 |
3 files changed, 15 insertions, 19 deletions
diff --git a/steuermann/run.py b/steuermann/run.py index e83fca2..63900dd 100644 --- a/steuermann/run.py +++ b/steuermann/run.py @@ -53,9 +53,6 @@ class runner(object): # index of nodes node_index = None - # dir where we write our logs - logdir = '' - # host_info_cache = None @@ -65,18 +62,17 @@ class runner(object): ##### # - def __init__( self, nodes, logdir ) : + def __init__( self, nodes ) : self.all_procs = { } self.node_index = nodes self.load_host_info() - self.logdir = logdir self.host_info_cache = { } self.howmany = { } ##### # start a process - def run( self, node, run_name, no_run = False, logfile_name = None ): + def run( self, node, run_name, logfile_name, no_run = False ): try : try : @@ -144,13 +140,6 @@ class runner(object): if debug : print "RUN",run - if logfile_name is None : - # make sure the log directory is there - logdir= self.logdir + "/%s"%(run_name) - - # create a name for the log file, but do not use / in the name - logfile_name = "%s/%s.log"%( logdir, node.name.replace('/','.') ) - try : os.makedirs( os.path.dirname(logfile_name) ) except OSError, e : @@ -160,6 +149,7 @@ class runner(object): raise # open the log file, write initial notes + print "LOGFILE",logfile_name logfile=open(logfile_name,"w") logfile.write('%s %s\n'%(datetime.datetime.now(),run)) logfile.flush() diff --git a/steuermann/run_all.py b/steuermann/run_all.py index 1e179a2..71cabd1 100644 --- a/steuermann/run_all.py +++ b/steuermann/run_all.py @@ -177,7 +177,7 @@ def run_interactive( xnodes, run_name, db) : register_database(db, run_name, xnodes) - runner = run.runner( xnodes, steuermann.config.logdir ) + runner = run.runner( xnodes ) for x in xnodes : xnodes[x].finished = 0 @@ -440,10 +440,7 @@ def run_step( runner, xnodes, run_name, db ) : else : try : - if runner.run(x, run_name, no_run=no_run) : - # returns true/false whether it actually ran it - it may not because of resource limits - db.execute("UPDATE sm_status SET start_time = ?, status = 'R' WHERE ( run = ? AND host = ? AND tablename = ? AND cmd = ? )", - ( str(datetime.datetime.now()), run_name, host, table, cmd ) ) + tmp = runner.run(x, run_name, no_run=no_run, logfile = make_log_file_name(run_name, host, table, cmd) ) except run.run_exception, e : now = str(datetime.datetime.now()) db.execute("UPDATE sm_status SET start_time=?, end_time=?, status='E', notes=? WHERE ( run=? AND host=? AND tablename=? AND cmd=? )", @@ -451,6 +448,11 @@ def run_step( runner, xnodes, run_name, db ) : x.finished = 1 no_sleep = 1 keep_running = 1 + else : + if tmp : + # returns true/false whether it actually ran it - it may not because of resource limits + db.execute("UPDATE sm_status SET start_time = ?, status = 'R' WHERE ( run = ? AND host = ? AND tablename = ? AND cmd = ? )", + ( str(datetime.datetime.now()), run_name, host, table, cmd ) ) db.commit() @@ -510,6 +512,10 @@ def info_callback_depth( db, run, tablename, host, cmd ) : return n.depth ##### +def make_log_file_name( run_name, table, host, cmd ) : + return '%s/run/%s/%s/%s/%s.log'%(steuermann.config.logdir, run_name, table, host, cmd) + if __name__ == '__main__' : main() + diff --git a/steuermann/run_cron.py b/steuermann/run_cron.py index 39d5be7..5779e1e 100644 --- a/steuermann/run_cron.py +++ b/steuermann/run_cron.py @@ -57,7 +57,7 @@ def main() : else : node.script_type = 'r' # remote - runner = steuermann.run.runner( nodes = { node.name : node }, logdir=None ) + runner = steuermann.run.runner( nodes = { node.name : node } ) runner.run( node=node, run_name='', logfile_name = steuermann.config.logdir + '/cron/' + logfile ) n = 0.1 |