Skip to content

Commit

Permalink
[bin] automatically execute rover exec when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Nov 2, 2017
1 parent a62e0ee commit 3143dcc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions apicast/bin/apicast
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ use Cwd qw(abs_path);

my $apicast = $ENV{APICAST_DIR} || abs_path(dirname(abs_path(__FILE__)) . '/..');
my $bindir = $apicast . '/bin';
my $lua_path = $ENV{LUA_PATH} || ';';
my $lua_path = $ENV{LUA_PATH};

chomp(my $rover = `which rover`);
if ($rover) { $rover = abs_path($rover) }

if ($rover && !$lua_path) {
exec '/usr/bin/env', $rover, 'exec', $0, @ARGV
} else {
$lua_path ||= ';';
}

chdir $apicast;

$ENV{LUA_PATH} = "$apicast/src/?.lua;${lua_path}";

exec '/usr/bin/env', 'resty',
"$bindir/cli", @ARGV;
my @args = ('resty', "$bindir/cli", @ARGV);

exec '/usr/bin/env', @args;

0 comments on commit 3143dcc

Please sign in to comment.