Commit 112ce96c authored by Karl Heyes's avatar Karl Heyes

Add optional pidfile. Writes process id of icecast to named file

svn path=/trunk/icecast/; revision=5674
parent b795bb58
......@@ -92,6 +92,7 @@
<logdir>@localstatedir@/log/@PACKAGE@</logdir>
<webroot>@pkgdatadir@/web</webroot>
<adminroot>@pkgdatadir@/admin</adminroot>
<pidfile>@pkgdatadir@/icecast.pid</pidfile>
<!-- Aliases: treat requests for 'source' path as being for 'dest' path
May be made specific to a port or bound address using the "port"
......
......@@ -303,6 +303,7 @@ This specifies a mountpoint that is used in the case of a source disconnect. If
&lt;paths&gt;
&lt;basedir&gt;./&lt;basedir&gt;
&lt;logdir&gt;./logs&lt;logdir&gt;
&lt;pidfile&gt;./icecast.pid&lt;pidfile&gt;
&lt;webroot&gt;./web&lt;webroot&gt;
&lt;adminroot&gt;./admin&lt;adminroot&gt;
&lt;alias source="/foo" dest="/bar"/&gt;
......@@ -318,6 +319,10 @@ This path is used in conjunction with the chroot settings, and specified the bas
<div class=indentedbox>
This path specifies the base directory used for logging. Both the error.log and access.log will be created relative to this directory.
</div>
<h4>pidfile</h4>
<div class=indentedbox>
This pathname specifies the file to write at startup and to remove at normal shutdown. The file contains the process id of the icecast process. This could be read and used for sending signals icecast.
</div>
<h4>webroot</h4>
<div class=indentedbox>
This path specifies the base directory used for all static file requests. This directory can contain all standard file types (including mp3s and ogg vorbis files). For example, if webroot is set to /var/share/icecast2, and a request for http://server:port/mp3/stuff.mp3 comes in, then the file /var/share/icecast2/mp3/stuff.mp3 will be served.
......
......@@ -130,6 +130,8 @@ void config_clear(ice_config_t *c)
xmlFree(c->webroot_dir);
if (c->adminroot_dir && c->adminroot_dir != CONFIG_DEFAULT_ADMINROOT_DIR)
xmlFree(c->adminroot_dir);
if (c->pidfile)
xmlFree(c->pidfile);
if (c->access_log && c->access_log != CONFIG_DEFAULT_ACCESS_LOG)
xmlFree(c->access_log);
if (c->error_log && c->error_log != CONFIG_DEFAULT_ERROR_LOG)
......@@ -644,6 +646,9 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
} else if (strcmp(node->name, "logdir") == 0) {
if (configuration->log_dir && configuration->log_dir != CONFIG_DEFAULT_LOG_DIR) xmlFree(configuration->log_dir);
configuration->log_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "pidfile") == 0) {
if (configuration->pidfile) xmlFree(configuration->pidfile);
configuration->pidfile = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "webroot") == 0) {
if (configuration->webroot_dir && configuration->webroot_dir != CONFIG_DEFAULT_WEBROOT_DIR) xmlFree(configuration->webroot_dir);
configuration->webroot_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
......
......@@ -96,6 +96,7 @@ typedef struct ice_config_tag
char *base_dir;
char *log_dir;
char *pidfile;
char *webroot_dir;
char *adminroot_dir;
aliases *aliases;
......
......@@ -45,6 +45,7 @@
#ifdef _WIN32
#define snprintf _snprintf
#define getpid _getpid
#endif
#undef CATMODULE
......@@ -336,6 +337,8 @@ static void _ch_root_uid_setup(void)
int main(int argc, char **argv)
{
int res, ret;
ice_config_t *config;
char *pidfile = NULL;
char filename[512];
char pbuf[1024];
......@@ -414,6 +417,18 @@ int main(int argc, char **argv)
return 1;
}
config = config_get_config_unlocked();
/* recreate the pid file */
if (config->pidfile)
{
FILE *f;
pidfile = strdup (config->pidfile);
if (pidfile && (f = fopen (config->pidfile, "w")) != NULL)
{
fprintf (f, "%d\n", getpid());
fclose (f);
}
}
/* Do this after logging init */
slave_initialize();
......@@ -435,6 +450,12 @@ int main(int argc, char **argv)
_shutdown_subsystems();
if (pidfile)
{
remove (pidfile);
free (pidfile);
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment