- PID file
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
0.5.5
|
||||
=====
|
||||
2-Apr-2004: - PID file
|
||||
31-Mar-2004: - accessctl.c: text correction in ERROR output
|
||||
30-Mar-2004: - Again '*' Contact header in unREGISTER
|
||||
- new: tools/extract_sip.pl
|
||||
|
||||
@@ -79,6 +79,12 @@ user = nobody
|
||||
# the specified directory path does exist!
|
||||
registration_file = /var/lib/siproxd/siproxd_registrations
|
||||
|
||||
######################################################################
|
||||
# PID file:
|
||||
# Where to create the PID file.
|
||||
# This file holds the PID of the main thread of siproxd.
|
||||
pid_file = /var/run/siproxd/siproxd.pid
|
||||
|
||||
######################################################################
|
||||
# global switch to control the RTP proxy behaviour
|
||||
# 0 - RTP proxy disabled
|
||||
|
||||
@@ -169,6 +169,7 @@ static int parse_config (FILE *configfile) {
|
||||
{ "outbound_proxy_port", TYP_INT4, &configuration.outbound_proxy_port },
|
||||
{ "registration_file", TYP_STRING ,&configuration.registrationfile },
|
||||
{ "log_calls", TYP_INT4, &configuration.log_calls },
|
||||
{ "pid_file", TYP_STRING ,&configuration.pid_file },
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -190,6 +190,23 @@ int main (int argc, char *argv[])
|
||||
INFO("daemonized, pid=%i", getpid());
|
||||
}
|
||||
|
||||
/* write PID file of main thread */
|
||||
if (configuration.pid_file) {
|
||||
FILE *pidfile;
|
||||
DEBUGC(DBCLASS_CONFIG,"creating PID file [%s]", configuration.pid_file);
|
||||
sts=unlink(configuration.pid_file);
|
||||
if ((sts==0) ||(errno == ENOENT)) {
|
||||
if ((pidfile=fopen(configuration.pid_file, "w"))) {
|
||||
fprintf(pidfile,"%i\n",getpid());
|
||||
fclose(pidfile);
|
||||
} else {
|
||||
WARN("couldn't create new PID file: %s", strerror(errno));
|
||||
}
|
||||
} else {
|
||||
WARN("couldn't delete old PID file: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize the RTP proxy */
|
||||
sts=rtpproxy_init();
|
||||
if (sts != STS_SUCCESS) {
|
||||
@@ -441,9 +458,20 @@ int main (int argc, char *argv[])
|
||||
} /* while TRUE */
|
||||
exit_prg:
|
||||
|
||||
/* dump current knwon SIP registrations */
|
||||
register_shut();
|
||||
INFO("properly terminating siproxd");
|
||||
|
||||
/* remove PID file */
|
||||
if (configuration.pid_file) {
|
||||
DEBUGC(DBCLASS_CONFIG,"deleting PID file [%s]", configuration.pid_file);
|
||||
sts=unlink(configuration.pid_file);
|
||||
if (sts != 0) {
|
||||
WARN("couldn't delete old PID file: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/* END */
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ struct siproxd_config {
|
||||
int outbound_proxy_port;
|
||||
char *registrationfile;
|
||||
int log_calls;
|
||||
char *pid_file;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user