10 * |
10 * |
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
13 */ |
13 */ |
14 |
14 |
15 define('GREY_VERSION', '0.1a4'); |
15 define('GREY_VERSION', '0.1a5'); |
16 |
16 |
17 // Try to trap termination signals to cleanly close the socket when needed |
17 // Try to trap termination signals to cleanly close the socket when needed |
18 // AmaroK sends a SIGTERM when it is shut down or the user requests to stop |
18 // AmaroK sends a SIGTERM when it is shut down or the user requests to stop |
19 // the script |
19 // the script |
20 if ( function_exists('pcntl_signal') ) |
20 if ( function_exists('pcntl_signal') ) |
23 declare(ticks=1); |
23 declare(ticks=1); |
24 |
24 |
25 // trap SIGTERM |
25 // trap SIGTERM |
26 pcntl_signal(SIGTERM, 'sigterm'); |
26 pcntl_signal(SIGTERM, 'sigterm'); |
27 pcntl_signal(SIGINT, 'sigterm'); |
27 pcntl_signal(SIGINT, 'sigterm'); |
28 pcntl_signal(SIGHUP, 'handle_refresh_signal'); |
|
29 } |
28 } |
30 |
29 |
31 @ini_set('display_errors', 'on'); |
30 @ini_set('display_errors', 'on'); |
32 |
31 |
33 // get the root |
32 // get the root |
173 $httpd->add_handler('scripts', 'dir', GREY_ROOT . '/scripts'); |
172 $httpd->add_handler('scripts', 'dir', GREY_ROOT . '/scripts'); |
174 $httpd->add_handler('favicon.ico', 'file', GREY_ROOT . '/amarok_icon.ico'); |
173 $httpd->add_handler('favicon.ico', 'file', GREY_ROOT . '/amarok_icon.ico'); |
175 $httpd->add_handler('apple-touch-icon.png', 'file', GREY_ROOT . '/apple-touch-icon.png'); |
174 $httpd->add_handler('apple-touch-icon.png', 'file', GREY_ROOT . '/apple-touch-icon.png'); |
176 $httpd->add_handler('spacer.gif', 'file', GREY_ROOT . '/spacer.gif'); |
175 $httpd->add_handler('spacer.gif', 'file', GREY_ROOT . '/spacer.gif'); |
177 $httpd->add_handler('trans80.png', 'file', GREY_ROOT . '/trans80.png'); |
176 $httpd->add_handler('trans80.png', 'file', GREY_ROOT . '/trans80.png'); |
|
177 $httpd->add_handler('offlinemode.png', 'file', GREY_ROOT . '/offlinemode.png'); |
|
178 $httpd->add_handler('offlinemodelarge.png', 'file', GREY_ROOT . '/offlinemodelarge.png'); |
178 $httpd->threader->ipc_register('reloadconfig', 'grey_reload_config'); |
179 $httpd->threader->ipc_register('reloadconfig', 'grey_reload_config'); |
|
180 $httpd->threader->ipc_register('reloadplaylist', 'rebuild_playlist_ipc'); |
179 // load all themes if forking is enabled |
181 // load all themes if forking is enabled |
180 // Themes are loaded when the playlist is requested. This is fine for |
182 // Themes are loaded when the playlist is requested. This is fine for |
181 // single-threaded operation, but if the playlist handler is only loaded |
183 // single-threaded operation, but if the playlist handler is only loaded |
182 // in a child process, we need to preload all themes into the parent before |
184 // in a child process, we need to preload all themes into the parent before |
183 // children can respond to theme resource requests. |
185 // children can respond to theme resource requests. |
210 burnout("Could not bind to the port $ip:$port. Is Greyhound already running? Sometimes browsers don't close off their connections until Greyhound has been dead for about a minute, so try starting Greyhound again in roughly 60 seconds. If that doesn't work, type \"killall -9 php\" at a terminal and try starting Greyhound again in 60 seconds."); |
212 burnout("Could not bind to the port $ip:$port. Is Greyhound already running? Sometimes browsers don't close off their connections until Greyhound has been dead for about a minute, so try starting Greyhound again in roughly 60 seconds. If that doesn't work, type \"killall -9 php\" at a terminal and try starting Greyhound again in 60 seconds."); |
211 } |
213 } |
212 burnout("Exception caught while running webserver:\n$e"); |
214 burnout("Exception caught while running webserver:\n$e"); |
213 } |
215 } |
214 |
216 |
215 function handle_refresh_signal() |
|
216 { |
|
217 global $httpd; |
|
218 if ( !is_object($httpd) ) |
|
219 // we're not serving yet. |
|
220 return false; |
|
221 |
|
222 // we've got an httpd instance; rebuild the playlist |
|
223 rebuild_playlist(); |
|
224 } |
|
225 |
|