| 1 | #!/usr/local/bin/perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = '0.09'; # VERSION | ||
| 7 | |||
| 8 | use Getopt::Long; | ||
| 9 | |||
| 10 | use Log::Log4perl; | ||
| 11 | |||
| 12 | use Video::PlaybackMachine::Config; | ||
| 13 | |||
| 14 | use Video::PlaybackMachine; | ||
| 15 | |||
| 16 | our $config = Video::PlaybackMachine::Config->config(); | ||
| 17 | |||
| 18 | MAIN: { | ||
| 19 | |||
| 20 | if ( $config->daemonize() ) { | ||
| 21 | my $start_time = time(); | ||
| 22 | |||
| 23 | while (1) { | ||
| 24 | |||
| 25 | # Spawn off a child to do actual running | ||
| 26 | my $pid; | ||
| 27 | if ( my $pid = fork ) { | ||
| 28 | sleep 5; | ||
| 29 | wait; | ||
| 30 | } | ||
| 31 | else { | ||
| 32 | |||
| 33 | open( STDERR, '>>' . $config->stderr_log() ) | ||
| 34 | or die "Couldn't open '" | ||
| 35 | . $config->stderr_log() | ||
| 36 | . "' for STDERR log: $!; stopped"; | ||
| 37 | |||
| 38 | Log::Log4perl::init( \( $config->log_config() ) ); | ||
| 39 | |||
| 40 | Video::PlaybackMachine->run($start_time); | ||
| 41 | } | ||
| 42 | |||
| 43 | } | ||
| 44 | |||
| 45 | } | ||
| 46 | else { | ||
| 47 | Video::PlaybackMachine->run(undef, 1); | ||
| 48 | } | ||
| 49 | |||
| 50 | } | ||
| 51 |