greyhound.php
changeset 32 86140ed9087d
parent 25 5c377ceb0e4c
child 33 3b4aef1efff6
equal deleted inserted replaced
27:20a36fe254c9 32:86140ed9087d
    21   declare(ticks=1);
    21   declare(ticks=1);
    22   
    22   
    23   // trap SIGTERM
    23   // trap SIGTERM
    24   pcntl_signal(SIGTERM, 'sigterm');
    24   pcntl_signal(SIGTERM, 'sigterm');
    25   pcntl_signal(SIGINT,  'sigterm');
    25   pcntl_signal(SIGINT,  'sigterm');
       
    26   pcntl_signal(SIGUSR1, 'handle_refresh_signal');
    26 }
    27 }
    27 
    28 
    28 //
    29 //
    29 // CONFIGURATION
    30 // CONFIGURATION
    30 //
    31 //
   152 }
   153 }
   153 catch( Exception $e )
   154 catch( Exception $e )
   154 {
   155 {
   155   burnout("Exception caught while running webserver:\n$e");
   156   burnout("Exception caught while running webserver:\n$e");
   156 }
   157 }
       
   158 
       
   159 function handle_refresh_signal()
       
   160 {
       
   161   global $httpd;
       
   162   if ( !is_object($httpd) )
       
   163     // we're not serving yet.
       
   164     return false;
       
   165     
       
   166   // we've got an httpd instance; rebuild the playlist
       
   167   rebuild_playlist();
       
   168   
       
   169   // if this is the parent, also ask the children to rebuild.
       
   170   if ( !defined('HTTPD_WS_CHILD') )
       
   171   {
       
   172     foreach ( $httpd->child_list as $pid )
       
   173     {
       
   174       posix_kill($pid, SIGUSR1);
       
   175     }
       
   176   }
       
   177 }