|
Last change
on this file since 102 was
102,
checked in by peter, 10 years ago
|
- allow a server_root key in the server config to set the root directory fdor the logs and pid file
- updated the cpanfile to include more of the modules required for the web app to operate
|
-
Property svn:executable set to
*
|
|
File size:
928 bytes
|
| Rev | Line | |
|---|
| [93] | 1 | #!/usr/bin/perl -w |
|---|
| 2 | use strict; |
|---|
| [54] | 3 | |
|---|
| [93] | 4 | use FindBin; |
|---|
| 5 | use lib "$FindBin::RealBin/lib"; |
|---|
| [65] | 6 | |
|---|
| [94] | 7 | use Getopt::Long; |
|---|
| 8 | use YAML; |
|---|
| [93] | 9 | use Plack::Runner; |
|---|
| 10 | use BookmarksApp; |
|---|
| [102] | 11 | use File::Spec::Functions qw{catfile}; |
|---|
| [93] | 12 | |
|---|
| [94] | 13 | GetOptions( |
|---|
| 14 | 'file=s' => \my $CONFIG_FILE, |
|---|
| 15 | ); |
|---|
| [93] | 16 | |
|---|
| [96] | 17 | $CONFIG_FILE ||= 'server.yml'; |
|---|
| [94] | 18 | -e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n"; |
|---|
| 19 | my $config = YAML::LoadFile($CONFIG_FILE); |
|---|
| 20 | my $app = BookmarksApp->new({ config => $config })->to_app; |
|---|
| 21 | |
|---|
| [102] | 22 | my $server_root = $config->{server_root} || '.'; |
|---|
| 23 | my $listen = ':' . ($config->{port} || 5000); |
|---|
| 24 | my $access_log = catfile($server_root, 'access'); |
|---|
| 25 | my $error_log = catfile($server_root, 'errors'); |
|---|
| 26 | my $pid_file = catfile($server_root, 'pid'); |
|---|
| [94] | 27 | |
|---|
| [93] | 28 | my $runner = Plack::Runner->new(server => 'Starman'); |
|---|
| [102] | 29 | $runner->parse_options( |
|---|
| 30 | '--daemonize', |
|---|
| 31 | '--listen', $listen, |
|---|
| 32 | '--pid', $pid_file, |
|---|
| 33 | '--error-log', $error_log, |
|---|
| 34 | '--access-log', $access_log, |
|---|
| 35 | ); |
|---|
| [93] | 36 | $runner->run($app); |
|---|
Note: See
TracBrowser
for help on using the repository browser.