-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ doc/api/ | |
node_modules | ||
.vagrant/ | ||
apicast/logs/ | ||
*.rock |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package = "apicast" | ||
version = "scm-1" | ||
source = { | ||
url = "git+https://github.com/3scale/apicast.git", | ||
branch = 'master' | ||
} | ||
description = { | ||
detailed = "3scale API Gateway", | ||
homepage = "https://github.com/3scale/apicast", | ||
license = "Apache License 2.0" | ||
} | ||
dependencies = { | ||
'lua-resty-http == 0.10-0', | ||
'inspect == 3.1.0-1', | ||
'router == 2.1-0', | ||
'lua-resty-jwt == 0.1.10-1', | ||
'datafile == 0.4-1', | ||
} | ||
build = { | ||
type = "make", | ||
makefile = 'apicast/Makefile', | ||
build_pass = false, | ||
build_variables = { | ||
CFLAGS='$(CFLAGS)' | ||
}, | ||
install_variables = { | ||
INST_PREFIX="$(PREFIX)", | ||
INST_BINDIR="$(BINDIR)", | ||
INST_LIBDIR="$(LIBDIR)", | ||
INST_LUADIR="$(LUADIR)", | ||
INST_CONFDIR="$(CONFDIR)", | ||
}, | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$(INST_LUADIR)/apicast: | ||
mkdir -p $@ | ||
|
||
install: $(INST_LUADIR)/apicast | ||
@echo --- install | ||
cp -R apicast/src/* $(INST_LUADIR)/ | ||
cp apicast/bin/apicast* $(INST_BINDIR)/ | ||
cp -r apicast/*.d apicast/conf $(INST_CONFDIR) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#! /usr/bin/env resty | ||
-- vim: set ft=lua: | ||
|
||
local datafile = require("datafile") | ||
local conf = datafile.path("conf", "r", "config") | ||
|
||
local ffi = require('ffi') | ||
ffi.cdef([=[ | ||
int setenv(const char*, const char*, int); | ||
char *strerror(int errnum); | ||
int execvp(const char *file, const char *argv[]); | ||
]=]) | ||
|
||
local string_array_t = ffi.typeof("const char *[?]") | ||
|
||
local function exec(filename, arg) | ||
local args = { filename } | ||
for i=1, #arg do | ||
args[i+1] = arg[i] | ||
end | ||
local cargv = string_array_t(#args + 1, args) | ||
cargv[#args] = nil | ||
ffi.C.execvp(filename, cargv) | ||
error(ffi.string(ffi.C.strerror(ffi.errno()))) | ||
end | ||
|
||
local function setenv(name, value, overwrite) | ||
local overwrite_flag = overwrite and 1 or 0 | ||
|
||
if ffi.C.setenv(name, value, overwrite_flag) == -1 then | ||
return nil, ffi.C.strerror(ffi.errno()) | ||
else | ||
return value | ||
end | ||
end | ||
|
||
local _, apicast = datafile.open('apicast', 'r', 'config', function(path) | ||
local f, err = io.open(path, "r") | ||
|
||
if f then | ||
local ok | ||
|
||
ok, err = f:read(1) | ||
f:close() | ||
|
||
if ok then | ||
return ok, path | ||
end | ||
end | ||
|
||
return nil, err | ||
end) | ||
|
||
if conf then | ||
setenv('APICAST_DIR', conf, true) | ||
print("CONF: ", conf) | ||
end | ||
print("APICAST: ", apicast) | ||
|
||
exec(apicast or 'apicast', arg) |