Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.932 2006/09/07 07:27:00 noring Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.933 2006/09/08 07:13:55 noring Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:6234:       dbm_cached_get( "local" )    ->query("REPLACE INTO compiled_formats (md5,full,enc) VALUES (%s,%s,%s)",    kmd5,pattern,encode_value( res, master()->MyCodec( res ) ) );    return compile_string(code)()->f;   }         static string cached_hostname = gethostname();    - class LogFile(string fname) + class LogFile(string fname, string|void compressor_program)   {    Stdio.File fd;    int opened;    -  +  // FIXME: compress_logs is limited to scanning files with filename +  // substitutions within a fixed directory (e.g. +  // "$LOGDIR/test/Log.%y-%m-%d", not "$LOGDIR/test/%y/Log.%m-%d"). +  Process.Process compressor_process; +  int last_compressor_scan_time; +  static void compress_logs(string fname, string active_log) +  { +  if(!compressor_program || !sizeof(compressor_program)) +  // No compressor program specified... +  return; +  if(compressor_process && !compressor_process->status()) +  // The compressor is already running... +  return; +  if(time(1) - last_compressor_scan_time < 300) +  // Scan for compressable files at most once every 5 minutes... +  return; +  last_compressor_scan_time = time(1); +  fname = roxen_path(fname); +  active_log = roxen_path(active_log); +  string dir = dirname(fname); +  foreach(sort(get_dir(dir) || ({})), string filename_candidate) +  { +  if(filename_candidate == basename(active_log)) +  // Don't try to compress the active log just yet... +  continue; +  if(Regexp("^"+replace(basename(fname), +  ({ "%y", "%m", "%d", "%h", "%H" }), +  ({ "[0-9][0-9][0-9][0-9]", "[0-9][0-9]", +  "[0-9][0-9]", "[0-9][0-9]", "(.+)" }))+"$")-> +  match(filename_candidate)) +  { +  string compress_file = combine_path(dir, filename_candidate); +  Stdio.Stat stat = file_stat(compress_file); +  if(!stat || time(1) < stat->mtime + 300) +  // Wait at least 5 minutes before compressing log file... +  continue; +  werror("Compressing log file %O\n", compress_file); +  compressor_process = Process.create_process(({ compressor_program, +  compress_file })); +  return; +  } +  } +  } +     void do_open()    {    mixed parent;    if (catch { parent = function_object(object_program(this_object())); } ||    !parent) {    // Our parent (aka the configuration) has been destructed.    // Time to die.    remove_call_out(do_open);    remove_call_out(do_close);    destruct();
Roxen.git/server/base_server/roxen.pike:6263:    m->year += 1900; // Adjust for years being counted since 1900    m->mon++; // Adjust for months being counted 0-11    if(m->mon < 10) m->mon = "0"+m->mon;    if(m->mday < 10) m->mday = "0"+m->mday;    if(m->hour < 10) m->hour = "0"+m->hour;    ff = replace(fname,({"%d","%m","%y","%h", "%H" }),    ({ (string)m->mday, (string)(m->mon),    (string)(m->year),(string)m->hour,    cached_hostname,    })); +  compress_logs(fname, ff);    mkdirhier( ff );    fd = open( ff, "wac" );    if(!fd)    {    remove_call_out( do_open );    call_out( do_open, 120 );    report_error(LOC_M(37, "Failed to open logfile")+" "+fname+" "   #if constant(strerror)    "(" + strerror(errno()) + ")"   #endif