Skip to content

Commit

Permalink
Allow 'all' ass a webserver option.
Browse files Browse the repository at this point in the history
  • Loading branch information
gphat committed Apr 27, 2012
1 parent 504976f commit 97c2b8e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/Dist/Zilla/Plugin/Dpkg/PerlbrewStarman.pm
Expand Up @@ -5,7 +5,7 @@ use Moose::Util::TypeConstraints;

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

enum 'WebServer', [qw(apache nginx)];
enum 'WebServer', [qw(apache nginx all)];

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

Expand Down Expand Up @@ -437,13 +437,16 @@ around '_generate_file' => sub {
$_[2]->{starman_port} = $self->starman_port;
$_[2]->{startup_time} = $self->startup_time;

if($self->web_server eq 'apache') {
$_[2]->{webserver_config_link} = '# Symlink to the apache config for the environment we`re in
$_[2]->{webserver_config_link} = '';
$_[2]->{webserver_restart} = '';

if(($self->web_server eq 'apache') || ($self->web_server eq 'all')) {
$_[2]->{webserver_config_link} .= '# Symlink to the apache config for the environment we`re in
if [ ! -e /etc/apache2/sites-available/$PACKAGE ]; then
ln /srv/$PACKAGE/config/apache/$PACKAGE.conf /etc/apache2/sites-available/$PACKAGE
fi
';
$_[2]->{webserver_restart} = 'a2enmod proxy proxy_http rewrite
$_[2]->{webserver_restart} .= 'a2enmod proxy proxy_http rewrite
a2ensite $PACKAGE
mkdir -p /var/log/apache2/$PACKAGE
if which invoke-rc.d >/dev/null 2>&1; then
Expand All @@ -452,13 +455,14 @@ around '_generate_file' => sub {
/etc/init.d/apache2 restart
fi
';
} else {
$_[2]->{webserver_config_link} = '# Symlink to the nginx config for the environment we`re in
}
if(($self->web_server eq 'nginx') || ($self->web_server eq 'all')) {
$_[2]->{webserver_config_link} .= '# Symlink to the nginx config for the environment we`re in
if [ ! -h /etc/nginx/sites-available/$PACKAGE ]; then
ln -s /srv/$PACKAGE/config/nginx/$PACKAGE.conf /etc/nginx/sites-available/$PACKAGE
fi
';
$_[2]->{webserver_restart} = 'if which invoke-rc.d >/dev/null 2>&1; then
$_[2]->{webserver_restart} .= 'if which invoke-rc.d >/dev/null 2>&1; then
invoke-rc.d nginx restart
else
/etc/init.d/nginx restart
Expand Down

0 comments on commit 97c2b8e

Please sign in to comment.