Changeset 634b4a3bb6507360b2be47824769d3a9740f533b

Show
Ignore:
Timestamp:
10/02/10 20:52:36 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1286052756 +0000
git-parent:

[c14d5c40b68a3d2304fb518a6f4970e78dc76a16]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1286052756 +0000
Message:

quick implementation of self-gliding... ideally we'd do this from the parent... futures. refs #319

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noitd.c

    rdb7317d r634b4a3  
    7676static char **disable_logs; 
    7777static int disable_logs_cnt = 0; 
     78static char *glider = NULL; 
    7879 
    7980#include "man/noitd.usage.h" 
     
    114115  enable_logs = calloc(argc, sizeof(*enable_logs)); 
    115116  disable_logs = calloc(argc, sizeof(*disable_logs)); 
    116   while((c = getopt(argc, argv, "Mhc:dDu:g:t:l:L:")) != EOF) { 
     117  while((c = getopt(argc, argv, "Mhc:dDu:g:t:l:L:G:")) != EOF) { 
    117118    switch(c) { 
     119      case 'G': 
     120        glider = strdup(optarg); 
     121        break; 
    118122      case 'M': 
    119123        strict_module_load = 1; 
     
    267271  char lockfile[PATH_MAX]; 
    268272  char user[32], group[32]; 
     273  char *trace_dir = NULL; 
    269274 
    270275  parse_clargs(argc, argv); 
     
    297302  if(debug) 
    298303    noit_debug->enabled = 1; 
     304 
     305  if(!glider) noit_conf_get_string(NULL, "/" APPNAME "/watchdog/@glider", &glider); 
     306  noit_watchdog_glider(glider); 
     307  noit_conf_get_string(NULL, "/" APPNAME "/watchdog/@tracedir", &trace_dir); 
     308  if(trace_dir) noit_watchdog_glider_trace_dir(trace_dir); 
    299309 
    300310  /* Lastly, run through all other system inits */ 
  • src/stratcond.c

    rdb7317d r634b4a3  
    7070static char **disable_logs; 
    7171static int disable_logs_cnt = 0; 
     72static char *glider = NULL; 
    7273 
    7374#include "man/stratcond.usage.h" 
     
    108109  enable_logs = calloc(argc, sizeof(*enable_logs)); 
    109110  disable_logs = calloc(argc, sizeof(*disable_logs)); 
    110   while((c = getopt(argc, argv, "Mrshc:dDu:g:t:l:L:")) != EOF) { 
     111  while((c = getopt(argc, argv, "Mrshc:dDu:g:t:l:L:G:")) != EOF) { 
    111112    switch(c) { 
    112113      case 'M': 
    113114        strict_module_load = 1; 
     115        break; 
     116      case 'G': 
     117        glider = strdup(optarg); 
    114118        break; 
    115119      case 'l': 
     
    177181  char conf_str[1024]; 
    178182  char user[32], group[32]; 
     183  char *trace_dir = NULL; 
    179184 
    180185  /* First initialize logging, so we can log errors */ 
     
    219224    noit_debug->enabled = 1; 
    220225 
     226  if(!glider) noit_conf_get_string(NULL, "/" APPNAME "/watchdog/@glider", &glider); 
     227  noit_watchdog_glider(glider); 
     228  noit_conf_get_string(NULL, "/" APPNAME "/watchdog/@tracedir", &trace_dir); 
     229  if(trace_dir) noit_watchdog_glider_trace_dir(trace_dir); 
     230 
    221231  /* Lastly, run through all other system inits */ 
    222232  if(!noit_conf_get_stringbuf(NULL, "/" APPNAME "/eventer/@implementation", 
  • src/utils/noit_watchdog.c

    ra269782 r634b4a3  
    5050 
    5151#define CHILD_WATCHDOG_TIMEOUT 5 /*seconds*/ 
     52const char *appname = "unknown"; 
     53const char *glider_path = NULL; 
     54const char *trace_dir = "/var/tmp"; 
     55 
     56void noit_watchdog_glider(const char *path) { 
     57  glider_path = path; 
     58} 
     59void noit_watchdog_glider_trace_dir(const char *path) { 
     60  trace_dir = path; 
     61} 
    5262 
    5363/* Watchdog stuff */ 
     
    8999} 
    90100 
     101int noit_monitored_child_pid = -1; 
     102 
     103void glideme(int sig) { 
     104  char cmd[1024]; 
     105  signal(sig, SIG_DFL); 
     106  snprintf(cmd, sizeof(cmd), "%s %d > %s/%s.%d.trc", 
     107           glider_path, noit_monitored_child_pid, 
     108           trace_dir, appname, noit_monitored_child_pid); 
     109  system(cmd); 
     110  kill(noit_monitored_child_pid, sig); 
     111} 
     112 
    91113int noit_watchdog_start_child(const char *app, int (*func)(), 
    92114                              int child_watchdog_timeout) { 
    93115  int child_pid; 
     116  appname = strdup(app); 
    94117  if(child_watchdog_timeout == 0) 
    95118    child_watchdog_timeout = CHILD_WATCHDOG_TIMEOUT; 
     
    103126      /* This sets up things so we start alive */ 
    104127      it_ticks_zero(); 
     128      /* trace handlers */ 
     129      noit_monitored_child_pid = getpid(); 
     130      if(glider_path) signal(SIGSEGV, glideme); 
    105131      /* run the program */ 
    106132      exit(func()); 
     
    154180  assert(__eventer); 
    155181 
    156   /* Setup our hearbeat */ 
     182 /* Setup our hearbeat */ 
    157183  e = eventer_alloc(); 
    158184  e->mask = EVENTER_RECURRENT; 
  • src/utils/noit_watchdog.h

    r5b63423 r634b4a3  
    7777  noit_watchdog_child_eventer_heartbeat(); 
    7878 
     79API_EXPORT(void) 
     80  noit_watchdog_glider(const char *path); 
     81 
     82API_EXPORT(void) 
     83  noit_watchdog_glider_trace_dir(const char *path); 
     84 
    7985#endif