Created
June 22, 2012 16:50
-
-
Save toritori0318/2973943 to your computer and use it in GitHub Desktop.
deploy script (App::Rad)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| servers=hogehoge.com,fugafuga.com,piyopiyo.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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