Skip to content

Commit

Permalink
publish apicast luarock
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed May 31, 2017
1 parent 595f51b commit 3708503
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ doc/api/
node_modules
.vagrant/
apicast/logs/
*.rock
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- APIcast module `balancer` method now accepts optional balancer [PR #362](https://github.com/3scale/apicast/pull/362)

### Added

- APIcast published to [luarocks.org](https://luarocks.org/modules/3scale/apicast) [PR #366](https://github.com/3scale/apicast/pull/366)

## [3.1.0-alpha1] - 2017-05-05

### Changed
Expand Down
33 changes: 33 additions & 0 deletions apicast-scm-1.rockspec
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)",
},
}
8 changes: 8 additions & 0 deletions apicast/Makefile
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)
2 changes: 1 addition & 1 deletion apicast/bin/apicast
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
fi

bin_dir=$(dirname "${path}")
apicast_dir="$( cd "${bin_dir}/.." && pwd )"
apicast_dir=${APICAST_DIR:-"$( cd "${bin_dir}/.." && pwd )"}

pick_openresty() {
for cmd in "$@"
Expand Down
60 changes: 60 additions & 0 deletions apicast/bin/apicast-lua
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)

0 comments on commit 3708503

Please sign in to comment.