[xiph-cvs] cvs commit: icecast/src main.c cfgfile.c cfgfile.h

Karl Heyes karl at xiph.org
Mon Dec 1 15:30:13 PST 2003



karl        03/12/01 18:30:13

  Modified:    doc      icecast2_config_file.html
               conf     icecast.xml.in
               src      main.c cfgfile.c cfgfile.h
  Log:
  Add optional pidfile. Writes process id of icecast to named file

Revision  Changes    Path
1.3       +5 -0      icecast/doc/icecast2_config_file.html

Index: icecast2_config_file.html
===================================================================
RCS file: /usr/local/cvsroot/icecast/doc/icecast2_config_file.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- icecast2_config_file.html	18 Nov 2003 17:23:55 -0000	1.2
+++ icecast2_config_file.html	1 Dec 2003 23:30:11 -0000	1.3
@@ -303,6 +303,7 @@
     <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 @@
 <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.

<p><p>1.4       +1 -0      icecast/conf/icecast.xml.in

Index: icecast.xml.in
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- icecast.xml.in	31 Oct 2003 19:16:12 -0000	1.3
+++ icecast.xml.in	1 Dec 2003 23:30:12 -0000	1.4
@@ -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"

<p><p>1.34      +21 -0     icecast/src/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- main.c	24 Jul 2003 16:21:22 -0000	1.33
+++ main.c	1 Dec 2003 23:30:12 -0000	1.34
@@ -45,6 +45,7 @@
 
 #ifdef _WIN32
 #define snprintf _snprintf
+#define getpid _getpid
 #endif
 
 #undef CATMODULE
@@ -336,6 +337,8 @@
 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 @@
         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 @@
 
     _shutdown_subsystems();
 
+    if (pidfile)
+    {
+        remove (pidfile);
+        free (pidfile);
+    }
+
     return 0;
 }
 

<p><p>1.4       +5 -0      icecast/src/cfgfile.c

Index: cfgfile.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/cfgfile.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- cfgfile.c	18 Nov 2003 00:59:51 -0000	1.3
+++ cfgfile.c	1 Dec 2003 23:30:13 -0000	1.4
@@ -130,6 +130,8 @@
         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 @@
         } 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);

<p><p>1.3       +1 -0      icecast/src/cfgfile.h

Index: cfgfile.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/cfgfile.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- cfgfile.h	23 Jul 2003 00:27:10 -0000	1.2
+++ cfgfile.h	1 Dec 2003 23:30:13 -0000	1.3
@@ -96,6 +96,7 @@
 
     char *base_dir;
     char *log_dir;
+    char *pidfile;
     char *webroot_dir;
     char *adminroot_dir;
     aliases *aliases;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list