Changeset 27397


Ignore:
Timestamp:
2013-05-23T13:09:48+12:00 (11 years ago)
Author:
jmt12
Message:

Allowing server out and err streams to be redirected to dev null

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/bin/script/TDBServer.pl

    r26995 r27397  
    5959# We need to do a little file locking
    6060use Fcntl qw(:flock); #import LOCK_* constants
    61 
    6261# Advanced child process control allowing bidirectional pipes
    6362use IPC::Run qw(harness start pump finish);
    64 
    6563# we need to run as a daemon
    6664use Proc::Daemon;
     65# Try and find the hostname
     66use Sys::Hostname;
    6767
    6868# The server will need to accept requests from multiple threads, and
     
    8787my $debug = 1;
    8888my $server;
    89 my $machine_name = `hostname -s`;
     89my $machine_name = (`hostname -s` || `hostname -a` || `hostname` || $ENV{'HOSTNAME'});
    9090chomp($machine_name);
    9191my $server_host = $machine_name . '.local';
     
    203203  {
    204204    print " * Spawning Daemon...\n" unless (!$debug);
    205     my $logs_dir = &util::filename_cat($ENV{'GSDLHOME'}, 'collect', $collection, 'logs');
    206     if (!-d $logs_dir)
    207     {
    208       mkdir($logs_dir, 0755);
    209     }
    210     my $daemon_out_path = &util::filename_cat($logs_dir, 'tdbserver.out');
    211     my $daemon_err_path = &util::filename_cat($logs_dir, 'tdbserver.err');
    212     $pid = Proc::Daemon::Init( { work_dir => getcwd(),
    213                                  child_STDOUT => $daemon_out_path,
    214                                  child_STDERR => $daemon_err_path,
    215                                } );
     205    if ($debug)
     206    {
     207      my $logs_dir = &util::filename_cat($ENV{'GSDLHOME'}, 'collect', $collection, 'logs');
     208      if (!-d $logs_dir)
     209      {
     210        mkdir($logs_dir, 0755);
     211      }
     212      my $daemon_out_path = &util::filename_cat($logs_dir, 'tdbserver.out');
     213      my $daemon_err_path = &util::filename_cat($logs_dir, 'tdbserver.err');
     214      $pid = Proc::Daemon::Init( { work_dir => getcwd(),
     215                                   child_STDOUT => $daemon_out_path,
     216                                   child_STDERR => $daemon_err_path,
     217                                 } );
     218    }
     219    else
     220    {
     221      # Streams to /dev/null
     222      $pid = Proc::Daemon::Init( { work_dir => getcwd(),
     223                                 } );
     224    }
    216225  }
    217226
Note: See TracChangeset for help on using the changeset viewer.