Changeset 8c8aea6bc50ed2cc0619d0585a079dc9a4de6a16

Show
Ignore:
Timestamp:
02/23/10 21:59:55 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1266962395 +0000
git-parent:

[c2d49f882d3f19081d30af3c228a002091bffd67]

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

lockfile as root node attribute in both noit.conf and stratcon.conf, closes #263

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit.conf.in

    r322ceb0 r8c8aea6  
    11<?xml version="1.0" encoding="utf8" standalone="yes"?> 
    2 <noit
     2<noit lockfile="/var/run/noitd.lock"
    33  <eventer> 
    44    <config> 
     
    4848    <feeds> 
    4949      <outlet name="feed"/> 
    50       <log name="check"> 
    51         <outlet name="error"/> 
    52       </log> 
     50      <log name="check"/> 
    5351      <log name="status"/> 
    5452      <log name="metrics"/> 
  • src/noitd.c

    r6de8198 r8c8aea6  
    4949#include "utils/noit_security.h" 
    5050#include "utils/noit_watchdog.h" 
     51#include "utils/noit_lockfile.h" 
    5152#include "noit_listener.h" 
    5253#include "noit_console.h" 
     
    316317    exit(-1); 
    317318  } 
     319 
     320  /* Acquire the lock so that we can throw an error if it doesn't work. 
     321   * If we've started -D, we'll have the lock. 
     322   * If not we will daemon and must reacquire the lock. 
     323   */ 
     324  if(noit_conf_get_stringbuf(NULL, "/" APPNAME "/@lockfile", 
     325                             conf_str, sizeof(conf_str))) { 
     326    if(noit_lockfile_acquire(conf_str) < 0) { 
     327      noitL(noit_stderr, "Failed to acquire lock: %s\n", conf_str); 
     328      exit(-1); 
     329    } 
     330  } 
     331 
    318332  if(foreground) return child_main(); 
    319333 
     
    326340  if(fork()) exit(0); 
    327341 
     342  /* Reacquire the lock */ 
     343  if(noit_conf_get_stringbuf(NULL, "/" APPNAME "/@lockfile", 
     344                             conf_str, sizeof(conf_str))) { 
     345    if(noit_lockfile_acquire(conf_str) < 0) { 
     346      noitL(noit_stderr, "Failed to acquire lock: %s\n", conf_str); 
     347      exit(-1); 
     348    } 
     349  } 
     350 
    328351  signal(SIGHUP, SIG_IGN); 
    329352  return noit_watchdog_start_child("noitd", child_main, 0); 
  • src/stratcon.conf.in

    r3d36f5a r8c8aea6  
    1 <stratcon> 
     1<?xml version="1.0" encoding="utf8" standalone="yes"?> 
     2<stratcon lockfile="/var/run/stratcond.lock"> 
    23  <eventer/> 
    34 
  • src/stratcond.c

    r6de8198 r8c8aea6  
    4646#include "utils/noit_security.h" 
    4747#include "utils/noit_watchdog.h" 
     48#include "utils/noit_lockfile.h" 
    4849#include "noit_listener.h" 
    4950#include "noit_console.h" 
     
    272273int main(int argc, char **argv) { 
    273274  int fd; 
     275  char conf_str[PATH_MAX]; 
    274276  parse_clargs(argc, argv); 
    275277 
     
    280282 
    281283  noit_watchdog_prefork_init(); 
     284 
     285  /* Acquire the lock so that we can throw an error if it doesn't work. 
     286   * If we've started -D, we'll have the lock. 
     287   * If not we will daemon and must reacquire the lock. 
     288   */ 
     289  if(noit_conf_get_stringbuf(NULL, "/" APPNAME "/@lockfile", 
     290                             conf_str, sizeof(conf_str))) { 
     291    if(noit_lockfile_acquire(conf_str) < 0) { 
     292      noitL(noit_stderr, "Failed to acquire lock: %s\n", conf_str); 
     293      exit(-1); 
     294    } 
     295  } 
    282296 
    283297  if(foreground) exit(child_main()); 
     
    291305  if(fork()) exit(0); 
    292306 
     307  /* Reacquire the lock */ 
     308  if(noit_conf_get_stringbuf(NULL, "/" APPNAME "/@lockfile", 
     309                             conf_str, sizeof(conf_str))) { 
     310    if(noit_lockfile_acquire(conf_str) < 0) { 
     311      noitL(noit_stderr, "Failed to acquire lock: %s\n", conf_str); 
     312      exit(-1); 
     313    } 
     314  } 
     315 
    293316  return noit_watchdog_start_child("stratcond", child_main, 0); 
    294317} 
  • src/utils/Makefile.in

    r4157a34 r8c8aea6  
    1212OBJS=noit_hash.o noit_skiplist.o noit_log.o noit_sem.o noit_str.o \ 
    1313        noit_b64.o noit_security.o noit_watchdog.o noit_mkdir.o \ 
    14         noit_getip.o
     14        noit_getip.o noit_lockfile.o
    1515        @ATOMIC_OBJS@ 
    1616