mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Add optional pidfile. Writes process id of icecast to named file
svn path=/trunk/icecast/; revision=5674
This commit is contained in:
parent
b795bb58dc
commit
112ce96cf0
@ -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
|
||||
<paths>
|
||||
<basedir>./<basedir>
|
||||
<logdir>./logs<logdir>
|
||||
<pidfile>./icecast.pid<pidfile>
|
||||
<webroot>./web<webroot>
|
||||
<adminroot>./admin<adminroot>
|
||||
<alias source="/foo" dest="/bar"/>
|
||||
@ -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;
|
||||
|
21
src/main.c
21
src/main.c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user