Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
added config sample; added hypnotoad settings in config
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap committed Feb 4, 2013
1 parent 7c5679a commit 1d5630d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
12 changes: 12 additions & 0 deletions helpers/mojolicious-radio-box.ini.sample
@@ -0,0 +1,12 @@
# config for mojolicious-radio-box.pl server
# place this file into ~/.cmus/mojolicious-radio-box.ini

# dir with m2u/pls playlist for internet radio
radio_playlist_dir = ~/Music/radio

# host and port for http server
listen_address = http://*:8080

# settings for hypnotoad server
hypnotoad_workers = 3
hypnotoad_accept_interval = 0.3
13 changes: 8 additions & 5 deletions mojolicious-radio-box.pl
Expand Up @@ -25,6 +25,9 @@ =head1 Mojolicious radio box
ini_file => "$ENV{HOME}/.cmus/mojolicious-radio-box.ini",
last_track_file => "$ENV{HOME}/.cmus/last_track.json",
playlist_file => "$ENV{HOME}/.cmus/playlist.pl",
listen_address => 'http://*:8080',
hypnotoad_workers => 2,
hypnotoad_accept_interval => 0.7,
);

# ------------------------------------------------------------------------------
Expand All @@ -35,7 +38,7 @@ sub init {
open my $FH, '<', $OPTIONS{ini_file} or die "Error open file: $!\n";
while (my $line = <$FH>) {
chomp $line;
next if $line =~ m/^ \s* \# .* $/x;
next if $line =~ m/^ \s* $/x || $line =~ m/^ \s* \# .* $/x;
my ($key, $value) = split /\s*=\s*/, $line, 2;
$OPTIONS{$key} = $value;
}
Expand Down Expand Up @@ -397,13 +400,13 @@ sub _cmus_parse_info {
app
->config(
hypnotoad => {
listen => ['http://*:8080'],
workers => 2,
accept_interval => 0.7,
listen => [$OPTIONS{listen_address}],
workers => $OPTIONS{hypnotoad_workers},
accept_interval => $OPTIONS{hypnotoad_accept_interval},
}
)
->secret('KxY0bCQwtVmQa2QdxqX8E0WtmVdpv362NJxofWP')
->start('daemon', '--listen=http://*:8080', @ARGV);
->start(@ARGV ? @ARGV : ("daemon", "--listen=$OPTIONS{listen_address}"));

__DATA__
@@ index.html.ep
Expand Down
11 changes: 7 additions & 4 deletions src/mojolicious-lite-radio-box-server.pl
Expand Up @@ -25,6 +25,9 @@ =head1 Mojolicious radio box
ini_file => "$ENV{HOME}/.cmus/mojolicious-radio-box.ini",
last_track_file => "$ENV{HOME}/.cmus/last_track.json",
playlist_file => "$ENV{HOME}/.cmus/playlist.pl",
listen_address => 'http://*:8080',
hypnotoad_workers => 2,
hypnotoad_accept_interval => 0.7,
);

# ------------------------------------------------------------------------------
Expand All @@ -41,13 +44,13 @@ =head1 Mojolicious radio box
app
->config(
hypnotoad => {
listen => ['http://*:8080'],
workers => 2,
accept_interval => 0.7,
listen => [$OPTIONS{listen_address}],
workers => $OPTIONS{hypnotoad_workers},
accept_interval => $OPTIONS{hypnotoad_accept_interval},
}
)
->secret('KxY0bCQwtVmQa2QdxqX8E0WtmVdpv362NJxofWP')
->start('daemon', '--listen=http://*:8080', @ARGV);
->start(@ARGV ? @ARGV : ("daemon", "--listen=$OPTIONS{listen_address}"));

__DATA__
@@ index.html.ep
Expand Down
2 changes: 1 addition & 1 deletion src/util.pm
Expand Up @@ -5,7 +5,7 @@ sub init {
open my $FH, '<', $OPTIONS{ini_file} or die "Error open file: $!\n";
while (my $line = <$FH>) {
chomp $line;
next if $line =~ m/^ \s* \# .* $/x;
next if $line =~ m/^ \s* $/x || $line =~ m/^ \s* \# .* $/x;
my ($key, $value) = split /\s*=\s*/, $line, 2;
$OPTIONS{$key} = $value;
}
Expand Down

0 comments on commit 1d5630d

Please sign in to comment.