Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created June 22, 2012 16:50
Show Gist options
  • Select an option

  • Save toritori0318/2973943 to your computer and use it in GitHub Desktop.

Select an option

Save toritori0318/2973943 to your computer and use it in GitHub Desktop.
deploy script (App::Rad)
use strict;
use warnings;
use App::Rad;
App::Rad->run();
# 初期化処理
sub setup {
my $c = shift;
$c->register_commands( {
start => 'server start',
restart => 'server restart',
stop => 'server stop',
deploy => 'server deploy',
});
}
# 全てのコマンドの直前に動くサブルーチン
sub pre_process {
my $c = shift;
# template
if ( $c->cmd eq 'some_command' and $> != 0 ) {
$c->cmd = 'default'; # or some standard error message
}
# load config env
my $env = $c->options->{env};
if(!$env || $env !~ /^(development|production)$/){
$c->cmd = 'default';
} else {
$c->load_config("${env}.config");
}
}
sub start {
my $c = shift;
for my $server (split /,/, $c->config->{servers}) {
# ssh & start command...
}
return $c->cmd . "is succeed";
}
sub restart {
my $c = shift;
for my $server (split /,/, $c->config->{servers}) {
# ssh & restart command...
}
return $c->cmd . "is succeed";
}
sub stop {
my $c = shift;
for my $server (split /,/, $c->config->{servers}) {
# ssh & stop command...
}
return $c->cmd . "is succeed";
}
sub deploy {
my $c = shift;
for my $server (split /,/, $c->config->{servers}) {
# rsync? scp? git clone ?
}
return $c->cmd . "is succeed";
}
servers=hogehoge.com,fugafuga.com,piyopiyo.com
servers=foo.com,bar.com,buz.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment