-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployToMast.pl
executable file
·46 lines (39 loc) · 1.05 KB
/
deployToMast.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl --
use strict;
use warnings;
use feature qw(say);
use Getopt::Long;
my $verbose =1;
GetOptions(
"verbose|v:+" => \$verbose,
) or die "bad options.";
# systemやcloseの結果を整形する
sub cmdResult($){
my($rv)=@_;
if( $rv == 0 ){
return;
}elsif( $rv == -1 ){
return "failed to execute: $!";
}elsif ( $rv & 127 ) {
return sprintf "signal %d", ($rv & 127);
}else {
return sprintf "exitCode %d",($rv>>8);
}
}
sub cmd($){
$verbose and say $_[0];
system $_[0];
my $error = cmdResult $?;
$error and die "$error cmd=$_[0]";
}
sub chdirOrThrow($){
my($dir)=@_;
chdir($dir) or die "chdir failed. $dir $!";
}
cmd qq(./gradlew shadowJar --stacktrace );
my $jarSrc = `ls -1t build/libs/*-all.jar|head -n 1`;
$jarSrc =~ s/\s+\z//;
(-f $jarSrc) or die "missing jarSrc [$jarSrc]";
my $appServerDir = "/m/subwaytooter-app-server/appServer2";
cmd qq(rsync -e ssh $jarSrc mast:$appServerDir/appFiles/appServer.jar);
cmd qq(ssh mast "cd $appServerDir && ./restartWeb.pl");