# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my ( $run_time_beg, $run_time_end, $options, $in, $out, $record, @vals, $i );
+my ( $options, $in, $out, $record, @vals, $i );
$options = Maasha::Biopieces::parse_options(
[
Maasha::Biopieces::put_record( $record, $out );
}
+Maasha::Biopieces::close_stream( $in );
+Maasha::Biopieces::close_stream( $out );
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
BEGIN
{
- $run_time_beg = Maasha::Biopieces::run_time();
-
- Maasha::Biopieces::log_biopiece();
+ Maasha::Biopieces::status_set();
}
END
{
- Maasha::Biopieces::close_stream( $in );
- Maasha::Biopieces::close_stream( $out );
-
- $run_time_end = Maasha::Biopieces::run_time();
-
- Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options );
+ Maasha::Biopieces::status_log();
}
$SIG{ 'TERM' } = \&sig_handler;
+sub status_set
+{
+ my ( $time_stamp, $script, $user, $pid, $file, $fh );
+
+ $time_stamp = Maasha::Common::time_stamp();
+ $user = Maasha::Common::get_user();
+ $script = Maasha::Common::get_scriptname();
+ $pid = Maasha::Common::get_processid();
+
+ $file = "$ENV{ 'BP_TMP' }/" . join( ".", $user, $script, $pid ) . ".status";
+ $fh = Maasha::Filesys::file_write_open( $file );
+
+ print $fh join( ";", $time_stamp, join( " ", @ARGV ) ) . "\n";
+
+ close $fh;
+}
+
+
+sub status_log
+{
+ my ( $time0, $time1, $script, $user, $pid, $file, $fh, $elap, $fh_global, $fh_local, $line, $args );
+
+ $time1 = Maasha::Common::time_stamp();
+ $user = Maasha::Common::get_user();
+ $script = Maasha::Common::get_scriptname();
+ $pid = Maasha::Common::get_processid();
+
+ $file = "$ENV{ 'BP_TMP' }/" . join( ".", $user, $script, $pid ) . ".status";
+ $fh = Maasha::Filesys::file_read_open( $file );
+ $line = <$fh>;
+ chomp $line;
+ close $fh;
+
+ unlink $file;
+
+ ( $time0, $args ) = split /;/, $line;
+
+ $elap = Maasha::Common::time_stamp_diff( $time0, $time1 );
+
+ $fh_global = Maasha::Filesys::file_append_open( "$ENV{ 'BP_LOG' }/biopieces.log" );
+ $fh_local = Maasha::Filesys::file_append_open( "$ENV{ 'HOME' }/.biopieces.log" );
+
+ print $fh_global join( "\t", $time0, $time1, $elap, $user, $script, $args ) . "\n";
+ print $fh_local join( "\t", $time0, $time1, $elap, $user, "$script $args" ) . "\n";
+
+ $fh_global->autoflush( 1 );
+ $fh_local->autoflush( 1 );
+
+ close $fh_global;
+ close $fh_local;
+}
+
+
sub log_biopiece
{
# Martin A. Hansen, January 2008.
}
+sub time_stamp_diff
+{
+ # Martin A. Hansen, June 2009.
+
+ # Return the difference between two time stamps in
+ # the time stamp format.
+
+ my ( $t0, # time stamp 0
+ $t1, # time stamp 1
+ ) = @_;
+
+ # Returns a time stamp string.
+
+ my ( $year0, $mon0, $day0, $hour0, $min0, $sec0,
+ $year1, $mon1, $day1, $hour1, $min1, $sec1,
+ $year, $mon, $day, $hour, $min, $sec );
+
+ $t0 =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
+ $year0 = $1;
+ $mon0 = $2;
+ $day0 = $3;
+ $hour0 = $4;
+ $min0 = $5;
+ $sec0 = $6;
+
+ $t1 =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/;
+ $year1 = $1;
+ $mon1 = $2;
+ $day1 = $3;
+ $hour1 = $4;
+ $min1 = $5;
+ $sec1 = $6;
+
+ $year = $year1 - $year0;
+ $mon = $mon1 - $mon0;
+ $day = $day1 - $day0;
+ $hour = $hour1 - $hour0;
+ $min = $min1 - $min0;
+ $sec = $sec1 - $sec0;
+
+ #return "$year-$mon-$day $hour:$min:$sec";
+ return join( ":", sprintf( "%02d", $hour ), sprintf( "%02d", $min ), sprintf( "%02d", $sec ) );
+}
+
+
sub process_running
{
# Martin A. Hansen, July 2008.