Changeset 65 in bookmarks


Ignore:
Timestamp:
02/03/14 14:04:40 (10 years ago)
Author:
peter
Message:
  • added a stop shell script
  • start takes an optional config file argument; defaults to "conf.yml"
  • app.psgi:
    • uses the CONFIG_FILE environment variable as its config file name
    • get_controller() takes an environment as its argument, instead of a Plack::Request
Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/app.psgi

    r63 r65  
    99use BookmarkController; 
    1010 
    11 #TODO: allow a different config file on the command line, or set options from the command line 
     11#TODO: allow individual options to be set via environment vars, too 
    1212 
    13 -e 'conf.yml' or die "Missing required conf.yml config file\n"; 
     13-e $ENV{CONFIG_FILE} or die "Config file $ENV{CONFIG_FILE} not found\n"; 
    1414 
    15 my $config = YAML::LoadFile('conf.yml'); 
     15my $config = YAML::LoadFile($ENV{CONFIG_FILE}); 
    1616 
    1717sub get_controller { 
    18     my $req = shift; 
     18    my $env = shift; 
     19    my $req = Plack::Request->new($env); 
    1920 
    2021    return BookmarkController->new({ 
     
    2829        GET { 
    2930            my ($env) = @_; 
    30             my $req = Plack::Request->new($env); 
    31             my $controller = get_controller($req); 
     31            my $controller = get_controller($env); 
    3232 
    3333            # check for a uri param, and if there is one present, 
     
    3535            # redirect to that bookmark, and if not, show the form 
    3636            # to create a new bookmark 
    37             if (defined $req->param('uri')) { 
     37            if (defined $controller->request->param('uri')) { 
    3838                return $controller->find_or_new; 
    3939            } 
     
    4444        POST { 
    4545            my ($env) = @_; 
    46             my $req = Plack::Request->new($env); 
    47             my $controller = get_controller($req); 
     46            my $controller = get_controller($env); 
    4847 
    4948            # create the bookmark and redirect to the new bookmark's edit form 
     
    5554        GET { 
    5655            my ($env) = @_; 
    57             my $req = Plack::Request->new($env); 
    58             my $controller = get_controller($req); 
     56            my $controller = get_controller($env); 
    5957 
    6058            return $controller->list; 
     
    6563        GET { 
    6664            my ($env) = @_; 
    67             my $req = Plack::Request->new($env); 
    68             my $controller = get_controller($req); 
     65            my $controller = get_controller($env); 
    6966 
    7067            return $controller->feed; 
     
    7572        GET { 
    7673            my ($env, $params) = @_; 
    77             my $req = Plack::Request->new($env); 
    78             my $controller = get_controller($req); 
     74            my $controller = get_controller($env); 
    7975 
    8076            return $controller->view($params->{id}); 
     
    8278        POST { 
    8379            my ($env, $params) = @_; 
    84             my $req = Plack::Request->new($env); 
    85             my $controller = get_controller($req); 
     80            my $controller = get_controller($env); 
    8681 
    8782            return $controller->update_and_redirect($params->{id}); 
     
    9287        GET { 
    9388            my ($env, $params) = @_; 
    94             my $req = Plack::Request->new($env); 
    95             my $controller = get_controller($req); 
     89            my $controller = get_controller($env); 
    9690 
    9791            return $controller->view_field($params->{id}, $params->{field}); 
  • trunk/start

    r59 r65  
    11#!/bin/sh 
    22 
     3export CONFIG_FILE=${1:-"conf.yml"} 
     4 
    35starman --listen :5000 --daemonize --pid pid --error-log errors --access-log access 
Note: See TracChangeset for help on using the changeset viewer.