Changeset 102 in bookmarks


Ignore:
Timestamp:
07/01/15 16:28:42 (9 years ago)
Author:
peter
Message:
  • 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
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cpanfile

    r92 r102  
    1010# web application 
    1111requires 'Plack', '1.0036'; 
     12requires 'Starman'; 
     13requires 'File::Pid'; 
    1214 
    1315# for opening the dbh handle 
  • trunk/start

    r96 r102  
    99use Plack::Runner; 
    1010use BookmarksApp; 
     11use File::Spec::Functions qw{catfile}; 
    1112 
    1213GetOptions( 
     
    1920my $app = BookmarksApp->new({ config => $config })->to_app; 
    2021 
    21 my $listen = ':' . ($config->{port} || 5000); 
     22my $server_root = $config->{server_root} || '.'; 
     23my $listen      = ':' . ($config->{port} || 5000); 
     24my $access_log  = catfile($server_root, 'access'); 
     25my $error_log   = catfile($server_root, 'errors'); 
     26my $pid_file    = catfile($server_root, 'pid'); 
    2227 
    2328my $runner = Plack::Runner->new(server => 'Starman'); 
    24 $runner->parse_options(qw{--listen}, $listen, qw{--daemonize --pid pid --error-log errors --access-log access}); 
     29$runner->parse_options( 
     30    '--daemonize', 
     31    '--listen',     $listen, 
     32    '--pid',        $pid_file, 
     33    '--error-log',  $error_log, 
     34    '--access-log', $access_log, 
     35); 
    2536$runner->run($app); 
  • trunk/stop

    r65 r102  
    1 #!/bin/bash 
     1#!/usr/bin/perl -w 
     2use strict; 
    23 
    3 kill `cat pid` 
     4use FindBin; 
     5use lib "$FindBin::RealBin/lib"; 
     6 
     7use Getopt::Long; 
     8use YAML; 
     9use File::Pid; 
     10use File::Spec::Functions qw{catfile}; 
     11 
     12GetOptions( 
     13    'file=s' => \my $CONFIG_FILE, 
     14); 
     15 
     16$CONFIG_FILE ||= 'server.yml'; 
     17-e $CONFIG_FILE or die "Config file $CONFIG_FILE not found\n"; 
     18my $config = YAML::LoadFile($CONFIG_FILE); 
     19 
     20my $server_root = $config->{server_root} || '.'; 
     21 
     22my $pid_file = File::Pid->new({ 
     23    file => catfile($server_root, 'pid'), 
     24}); 
     25 
     26if (my $pid = $pid_file->running) { 
     27    kill 'TERM', $pid; 
     28} 
Note: See TracChangeset for help on using the changeset viewer.