October 21st, 2009 by Maarten
No comments »
On my XBMC mediacenter I have a lot of DVD’s on disk, but XBMC doesn’t handle them very well. They are not recognized and the individual .VOB files in the folders show up. This makes it hard for less technical family members to start playing the video. This is why I wanted to test if iso images make it better/easier.
On Ubuntu it’s easy to convert dvd files to iso images. First install GenISOimage:
$ apt-get install genisoimage
After that go to the directory with the VIDEO_TS and AUDIO_TS subfolders and start the conversion:
$ genisoimage -dvd-video -o dvdimage.iso /folder_with_dvd_files/
October 2nd, 2009 by Maarten
No comments »
I needed to run a PHP script in the background on my Ubuntu 8.04 server, but didn’t know how to do this. Googling around I found the following script to daemonize PHP scripts on bipinb.com:
<?php
declare(ticks=1);
$pid = pcntl_fork();
if ($pid == -1) {
die("could not fork");
} else
if ($pid) {
exit();
// we are the parent
} else {
// we are the child
}
// detatch from the controlling terminal
if (posix_setsid() == -1) {
die("could not detach from terminal");
}
$posid=posix_getpid();
$fp = fopen("/var/run/process.pid", "w");
fwrite($fp, $posid);
fclose($fp);
// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
// loop forever performing tasks
// **** place your main PHP code here ****
while (1) {
// **** place the PHP code that loops in here ****
}
fclose($fp);
function sig_handler($signo) {
switch ($signo) {
case SIGTERM:
// handle shutdown tasks
exit;
break;
case SIGHUP:
// handle restart tasks
break;
default:
// handle all other signals
}
}
?>
I inserted my code and ran the script from the console. It all looked good, but found that whenever I left the console, the script would stop.
After some more googling I ended up on kevin.vanzonneveld.net, where I found a lot of information on creating daemons in PHP. In the troubleshooting area I found the following:
Don’t use echo()
Echo writes to the STDOUT of your current session. If you logout, that will cause fatal errors and the daemon to die. Use System_Daemon::log() instead.
This was the problem… in my PHP code I had some echo statements. When I deleted them, my PHP daemon was (and stayed) alive!
October 2nd, 2009 by Maarten
1 comment »
For everything there is a first time… this is my first post on my fresh installed blog! From now on I will be posting my explorings and experiments with technology.