mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:41:59 +01:00
added a reloading utility to the contrib section
This commit is contained in:
parent
bd38a40101
commit
e9cbc803ab
38
contrib/reload/Makefile.in
Normal file
38
contrib/reload/Makefile.in
Normal file
@ -0,0 +1,38 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
mandir = @mandir@
|
||||
datarootdir = @datarootdir@
|
||||
localstatedir = @localstatedir@
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
||||
DEFS = @defs@
|
||||
INCDIR = -I. -I.. -I../.. -I../../src -I../src @INCDIR@ @sql_includes@
|
||||
LIBDIR = -L. @LIBDIR@ @LDFLAGS@ -L../src
|
||||
LIBS = @LIBS@ @sql_libs@
|
||||
RUNNING_USER = @RUNNING_USER@
|
||||
RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)`
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
all: pilerreload
|
||||
|
||||
pilerreload: pilerreload.c ../../src/libpiler.a
|
||||
$(CC) $(CFLAGS) $(INCDIR) $(DEFS) -o $@ $< -lpiler $(LIBS) $(LIBDIR)
|
||||
|
||||
install:
|
||||
|
||||
clean:
|
||||
rm -f pilerreload
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
53
contrib/reload/pilerreload.c
Normal file
53
contrib/reload/pilerreload.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* pilerreload.c, SJ
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <piler.h>
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
char *configfile = CONFIG_FILE;
|
||||
struct __config cfg;
|
||||
|
||||
|
||||
void fatal(char *s){
|
||||
printf("pilerctl: fatal: %s\n", s);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
char buf[SMALLBUFSIZE];
|
||||
int pid;
|
||||
FILE *f;
|
||||
|
||||
cfg = read_config(CONFIG_FILE);
|
||||
|
||||
f = fopen(cfg.pidfile, "r");
|
||||
if(!f) fatal("cannot open pidfile");
|
||||
|
||||
if(fgets(buf, sizeof(buf)-2, f) == NULL) fatal("cannot read pidfile");
|
||||
|
||||
fclose(f);
|
||||
|
||||
pid = atoi(buf);
|
||||
|
||||
if(pid > 1) kill(pid, SIGHUP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user