Dist-Zilla-Plugin-Dpkg-PerlbrewStarman

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Dist-Zilla-Plugin-Dpkg-PerlbrewStarman

0.16 Apr 10 2013

0.16 Apr 10 2013
  - Changed hard links to symbolic links (Jakob Voss)
  - Added new configuration attributes (Jakob Voss)
     - starman_workers - number of Starman workers (default: 5)
     - psgi_script - location of the PSGI (default: script/$PACKAGE.psgi)
  - Add the selection of web server to the list of package dependencies
  - Documentation overhaul

0.15 Dec 19 2012
  - Added support for specifying additional Apache modules to enable

0.14 Aug 23 2012
  - Fix another instance of rm being called without the -f flag.  This prevents
    dpkg from failing due to non-existant files.

Changes  view on Meta::CPAN

0.06 Jan 9 2012
  - Define APPLIB in defaults so restart works. (thanks Mike Eldridge)

0.05 Jan 4 2012
  - Fix bits of the postrm that weren't removing correctly

0.04 Dec 28 2011
  - Fix typo in path name

0.03 Dec 21 2011
  - Add starman_port

0.02 Dec 21 2011

0.01
  - First version, released on an unsuspecting world.

META.json  view on Meta::CPAN

{
   "abstract" : "Generate dpkg files for your perlbrew-backed, starman-based perl app",
   "author" : [
      "Cory G Watson <gphat@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 4.300006, CPAN::Meta::Converter version 2.113640",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.json  view on Meta::CPAN

      },
      "test" : {
         "requires" : {
            "Test::More" : 0
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman/issues"
      },
      "homepage" : "https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman",
      "repository" : {
         "type" : "git",
         "url" : "https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman.git",
         "web" : "https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman"
      }
   },
   "version" : "0.16"
}

META.yml  view on Meta::CPAN

---
abstract: 'Generate dpkg files for your perlbrew-backed, starman-based perl app'
author:
  - 'Cory G Watson <gphat@cpan.org>'
build_requires:
  Test::More: 0
configure_requires:
  ExtUtils::MakeMaker: 6.30
dynamic_config: 0
generated_by: 'Dist::Zilla version 4.300006, CPAN::Meta::Converter version 2.113640'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: Dist-Zilla-Plugin-Dpkg-PerlbrewStarman
requires:
  Dist::Zilla::Plugin::Dpkg: 0.05
  Moose: 0
  Moose::Util::TypeConstraints: 0
resources:
  bugtracker: https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman/issues
  homepage: https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman
  repository: https://github.com/tripside/dist-zilla-plugin-dpkg-perlbrewstarman.git
version: 0.16

Makefile.PL  view on Meta::CPAN

use strict;
use warnings;



use ExtUtils::MakeMaker 6.30;



my %WriteMakefileArgs = (
  "ABSTRACT" => "Generate dpkg files for your perlbrew-backed, starman-based perl app",
  "AUTHOR" => "Cory G Watson <gphat\@cpan.org>",
  "BUILD_REQUIRES" => {
    "Test::More" => 0
  },
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.30"
  },
  "DISTNAME" => "Dist-Zilla-Plugin-Dpkg-PerlbrewStarman",
  "EXE_FILES" => [],
  "LICENSE" => "perl",

README  view on Meta::CPAN



This archive contains the distribution Dist-Zilla-Plugin-Dpkg-PerlbrewStarman,
version 0.16:

  Generate dpkg files for your perlbrew-backed, starman-based perl app

This software is copyright (c) 2013 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.


README.mkdn  view on Meta::CPAN

# NAME

Dist::Zilla::Plugin::Dpkg::PerlbrewStarman - Generate dpkg files for your perlbrew-backed, starman-based perl app

# VERSION

version 0.16

# SYNOPSIS

A minimal directory structure for application foo:

    lib/
    root/
    script/foo.psgi
    config/nginx/foo.conf
    perlbrew/bin/starman

A minimal configuration:

    [Dpkg::PerlbrewStarman]
    web_server      = nginx
    starman_port    = 6000

A configuration showing optional attributes and their defaults:

    [Dpkg::PerlbrewStarman]
    web_server      = nginx
    starman_port    = 6000
    psgi_script     = script/foo.psgi
    starman_workers = 5
    startup_time    = 30

A configuration showing optional attributes that have no defaults:

    [Dpkg::PerlbrewStarman]
    web_server      = apache
    starman_port    = 6000
    apache_modules  = ldap ssl
    uid             = 782

# DESCRIPTION

This [Dist::Zilla](http://search.cpan.org/perldoc?Dist::Zilla) plugin generates Debian control files that are
suitable for packaging a self-contained Plack application utilizing the
Starman preforking PSGI HTTP server.  Key features include supporting an
independent perl environment and the generation and installation of init
scripts to manage the service.

README.mkdn  view on Meta::CPAN

- /etc/default/$PACKAGE
- /var/log/$PACKAGE
- /etc/apache2/sites-available/$PACKAGE => /srv/$PACKAGE/config/apache/$PACKAGE.conf
- /etc/nginx/sites-available/$PACKAGE => /srv/$PACKAGE/config/nginx/$PACKAGE.conf
- /etc/$PACKAGE => /srv/$PACKAGE/config

## Environment

By default, `/srv/$PACKAGE/perlbrew/bin` is prepended to the `PATH` by
way of the `PERLBREW_PATH` variable in `/etc/default/$PACKAGE`.  The
`starman` binary must be present in the path, else the service will
fail to start.

The application runs as user $PACKAGE by way of the --user argument to
[Starman](http://search.cpan.org/perldoc?Starman).  Starman flags are specified by the `DAEMON_ARGS` variable
in `/etc/default/$PACKAGE`.

# SEE ALSO

\* [Dist::Zilla::Plugin::ChangelogFromGit::Debian](http://search.cpan.org/perldoc?Dist::Zilla::Plugin::ChangelogFromGit::Debian)
\* [Dist::Zilla::Deb](http://search.cpan.org/perldoc?Dist::Zilla::Deb)

# ATTRIBUTES

## starman\_port

The port to use for starman (required).

## starman\_workers

The number of starman workers (5 by default).

## psgi\_script

Location of the psgi script started by starman. By default this is
`script/$PACKAGE.psgi`.

## startup\_time

The amount of time (in seconds) that the init script will wait on startup. Some
applications may require more than the default amount of time (30 seconds).

## uid

The UID of the user we're adding for the package. This is helpful for syncing

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN


use Moose::Util::TypeConstraints;

extends 'Dist::Zilla::Plugin::Dpkg';

enum 'WebServer', [qw(apache nginx all)];
subtype 'ApacheModule', as 'Str', where { $_ =~ /^[a-z_]+$/ };
subtype 'ApacheModules', as 'ArrayRef[ApacheModule]', message { 'The value provided for apache_modules does not look like a list of whitespace-separated Apache modules' };
coerce 'ApacheModules', from 'Str', via { [ split /\s+/ ] };

#ABSTRACT: Generate dpkg files for your perlbrew-backed, starman-based perl app


has '+conffiles_template_default' => (
    default => '/etc/default/{$package_name}
/etc/init.d/{$package_name}
'
);

has '+control_template_default' => (
    default => 'Source: {$package_name}

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

APP="{$package_name}"
APPDIR="/srv/$APP"
APPLIB="/srv/$APP/lib"
APPUSER={$package_name}

PSGIAPP="{$psgi_script}"
PIDFILE="/var/run/$APP.pid"

PERLBREW_PATH="$APPDIR/perlbrew/bin"

DAEMON_ARGS="-Ilib $PSGIAPP --daemonize --user $APPUSER --preload-app --workers {$starman_workers} --pid $PIDFILE --port {$starman_port} --host 127.0.0.1 --error-log /var/log/$APP/error.log"
'
);

has '+init_template_default' => (
    default => '#!/bin/sh
### BEGIN INIT INFO
# Provides:          {$package_name}
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

# Author: {$author}

DESC={$package_name}
NAME={$package_name}
SCRIPTNAME=/etc/init.d/$NAME

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

PATH=$PERLBREW_PATH:$PATH
DAEMON=`which starman`

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

check_running() \{
    [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

build:
	dh_testdir
	dh_auto_build

%:
	dh $@ --without perl --without auto_configure
'
);


has 'starman_port' => (
    is => 'ro',
    isa => 'Str',
    required => 1
);


has 'starman_workers' => (
    is => 'ro',
    isa => 'Str',
    default => 5
);


has 'psgi_script' => (
    is => 'ro',
    isa => 'Str',
    default => sub {

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

    my $orig = shift;
    my $self = shift;
	my $file = shift;
	my $required = shift;
	my $vars = shift;

    if($self->has_uid) {
      $vars->{uid} = '--uid '.$self->uid;
    }

    $vars->{starman_port} = $self->starman_port;
    $vars->{starman_workers} = $self->starman_workers;
    $vars->{startup_time} = $self->startup_time;

    if(($self->web_server eq 'apache') || ($self->web_server eq 'all')) {
        $vars->{package_binary_depends} .= ', apache2';
        $vars->{webserver_config_link} .= '# Symlink to the apache config for this environment
        rm -f /etc/apache2/sites-available/$PACKAGE
        ln -s /srv/$PACKAGE/config/apache/$PACKAGE.conf /etc/apache2/sites-available/$PACKAGE
';
        $vars->{webserver_restart} .= 'a2enmod proxy proxy_http rewrite ';
		$vars->{webserver_restart} .= join ' ', @{ $self->apache_modules || [] };

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

};


1;

__END__
=pod

=head1 NAME

Dist::Zilla::Plugin::Dpkg::PerlbrewStarman - Generate dpkg files for your perlbrew-backed, starman-based perl app

=head1 VERSION

version 0.16

=head1 SYNOPSIS

A minimal directory structure for application foo:

    lib/
    root/
    script/foo.psgi
    config/nginx/foo.conf
    perlbrew/bin/starman

A minimal configuration:

    [Dpkg::PerlbrewStarman]
    web_server      = nginx
    starman_port    = 6000

A configuration showing optional attributes and their defaults:

    [Dpkg::PerlbrewStarman]
    web_server      = nginx
    starman_port    = 6000
    psgi_script     = script/foo.psgi
    starman_workers = 5
    startup_time    = 30

A configuration showing optional attributes that have no defaults:

    [Dpkg::PerlbrewStarman]
    web_server      = apache
    starman_port    = 6000
    apache_modules  = ldap ssl
    uid             = 782

=head1 DESCRIPTION

This L<Dist::Zilla> plugin generates Debian control files that are
suitable for packaging a self-contained Plack application utilizing the
Starman preforking PSGI HTTP server.  Key features include supporting an
independent perl environment and the generation and installation of init
scripts to manage the service.

lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm  view on Meta::CPAN

=item * /etc/nginx/sites-available/$PACKAGE => /srv/$PACKAGE/config/nginx/$PACKAGE.conf

=item * /etc/$PACKAGE => /srv/$PACKAGE/config

=back

=head2 Environment

By default, C</srv/$PACKAGE/perlbrew/bin> is prepended to the C<PATH> by
way of the C<PERLBREW_PATH> variable in C</etc/default/$PACKAGE>.  The
C<starman> binary must be present in the path, else the service will
fail to start.

The application runs as user $PACKAGE by way of the --user argument to
L<Starman>.  Starman flags are specified by the C<DAEMON_ARGS> variable
in C</etc/default/$PACKAGE>.

=head1 SEE ALSO

* L<Dist::Zilla::Plugin::ChangelogFromGit::Debian>
* L<Dist::Zilla::Deb>

=head1 ATTRIBUTES

=head2 starman_port

The port to use for starman (required).

=head2 starman_workers

The number of starman workers (5 by default).

=head2 psgi_script

Location of the psgi script started by starman. By default this is
C<script/$PACKAGE.psgi>.

=head2 startup_time

The amount of time (in seconds) that the init script will wait on startup. Some
applications may require more than the default amount of time (30 seconds).

=head2 uid

The UID of the user we're adding for the package. This is helpful for syncing



( run in 0.625 second using v1.01-cache-2.11-cpan-e93a5daba3e )