-
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.
Merge pull request #449 from 3scale/templating
template nginx configuration with liquid
- Loading branch information
Showing
17 changed files
with
561 additions
and
225 deletions.
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
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
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 |
---|---|---|
@@ -1,20 +1,23 @@ | ||
busted 2.0.rc12-1 | ||
dkjson 2.5-2 | ||
inspect 3.1.0-1 | ||
ldoc 1.4.6-2 | ||
lua-resty-env 0.4.0-1 | ||
lua-resty-http 0.10-0 | ||
lua-resty-iputils 0.3.0-1 | ||
lua-resty-jwt 0.1.10-1 | ||
lua-resty-repl 0.0.6-0 | ||
lua-resty-url 0.2.0-1 | ||
lua-term 0.7-1 | ||
lua_cliargs 3.0-1 | ||
luafilesystem 1.7.0-2 | ||
luassert 1.7.10-0 | ||
luasystem 0.2.1-0 | ||
markdown 0.33-1 | ||
mediator_lua 1.1.2-0 | ||
penlight 1.5.4-1 | ||
router 2.1-0 | ||
say 1.3-1 | ||
argparse 0.5.0-1| | ||
busted 2.0.rc12-1| | ||
dkjson 2.5-2| | ||
inspect 3.1.0-1| | ||
ldoc 1.4.6-2| | ||
liquid scm-1|811a73e38fdd9fdea116be4baf310ca326b96c77 | ||
lua-resty-env 0.4.0-1| | ||
lua-resty-execvp 0.1.0-1| | ||
lua-resty-http 0.11-0| | ||
lua-resty-iputils 0.3.0-1| | ||
lua-resty-jwt 0.1.11-0| | ||
lua-resty-repl 0.0.6-0|3878f41b7e8f97b1c96919db19dbee9496569dda | ||
lua-resty-url 0.2.0-1| | ||
lua-term 0.7-1| | ||
lua_cliargs 3.0-1| | ||
luafilesystem 1.7.0-2| | ||
luassert 1.7.10-0| | ||
luasystem 0.2.1-0| | ||
markdown 0.33-1| | ||
mediator_lua 1.1.2-0| | ||
penlight 1.5.4-1| | ||
router 2.1-0| | ||
say 1.3-1| |
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 |
---|---|---|
@@ -1,130 +1,27 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings FATAL => 'all'; | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
use File::Basename; | ||
use Cwd qw(abs_path); | ||
|
||
script=${BASH_SOURCE[0]} | ||
if (readlink -f "${script}" > /dev/null 2>&1); then | ||
path=$(readlink -f "${script}") | ||
elif (readlink "${script}" > /dev/null 2>&1); then | ||
path="$(dirname "${script}")/$(readlink "${script}")" | ||
else | ||
path="${script}" | ||
fi | ||
my $apicast = $ENV{APICAST_DIR} || abs_path(dirname(abs_path(__FILE__)) . '/..'); | ||
my $bindir = $apicast . '/bin'; | ||
my $lua_path = $ENV{LUA_PATH}; | ||
|
||
bin_dir=$(dirname "${path}") | ||
apicast_dir=${APICAST_DIR:-"$( cd "${bin_dir}/.." && pwd )"} | ||
chomp(my $rover = `which rover`); | ||
if ($rover) { $rover = abs_path($rover) } | ||
|
||
pick_openresty() { | ||
for cmd in "$@" | ||
do | ||
if (${cmd} -V > /dev/null 2>&1); then | ||
echo "${cmd}" | ||
exit 0 | ||
fi | ||
done | ||
|
||
(>&2 echo "ERROR: Could not find openresty executable in your PATH.") | ||
(>&2 echo "Make sure you have one of: $(printf "%s " "$@")") | ||
exit 1 | ||
} | ||
|
||
openresty_binary=${APICAST_OPENRESTY_BINARY:-$(pick_openresty openresty-debug openresty nginx)} | ||
log_level=${APICAST_LOG_LEVEL:-warn} | ||
log_file=${APICAST_LOG_FILE:-stderr} | ||
log_levels=(emerg alert crit error warn notice info debug) | ||
((max_log_level=${#log_levels[@]}-1)) | ||
|
||
for ((i=0; i < ${#log_levels[@]}; i++)); do | ||
ll=${log_levels[i]} | ||
declare -r "log_level_${ll}=$i" | ||
done | ||
|
||
log="log_level_${log_level}" | ||
log_level="${!log}" | ||
|
||
daemon=off | ||
worker_processes=${APICAST_WORKERS:-1} | ||
|
||
usage () { | ||
cat <<-USAGE | ||
Usage $0 | ||
-h Show this help | ||
-c <file> Path to custom config file (JSON). | ||
-d Daemonize | ||
-v Increase verbosity (can be repeated) | ||
-i Cache configuration for N seconds. Using 0 will reload on every request (not for production). | ||
-w <workers> Number of worker processes to start. | ||
-m <on|off> Whether to start worker processes. Only for development. | ||
-s <signal> Send signal to a master process: stop, quit, reopen, reload | ||
-p <pid> Path to the PID file. | ||
-b Load configuration on boot. | ||
-e Deployment environment. Can be staging or production. | ||
USAGE | ||
if ($rover && !$lua_path) { | ||
exec '/usr/bin/env', $rover, 'exec', $0, @ARGV | ||
} else { | ||
$lua_path ||= ';'; | ||
} | ||
|
||
main=("") | ||
args=("") | ||
|
||
while getopts ":dc:hvbqi:rw:m:s:p:e:" opt; do | ||
case "${opt}" in | ||
d) | ||
daemon="on" | ||
;; | ||
c) | ||
export APICAST_CONFIGURATION="$OPTARG" | ||
;; | ||
b) | ||
export APICAST_CONFIGURATION_LOADER="boot" | ||
;; | ||
v) | ||
log_level=$((log_level == max_log_level ? max_log_level : log_level+1)) | ||
;; | ||
q) | ||
log_level=$((log_level == 0 ? 0 : log_level-1)) | ||
;; | ||
i) | ||
export APICAST_CONFIGURATION_CACHE="${OPTARG}" | ||
;; | ||
e) | ||
export THREESCALE_DEPLOYMENT_ENV="${OPTARG}" | ||
;; | ||
w) | ||
worker_processes=${OPTARG} | ||
;; | ||
m) | ||
main+=("master_process ${OPTARG};") | ||
;; | ||
p) | ||
main+=("pid ${PWD}/${OPTARG};") | ||
;; | ||
s) | ||
args+=("-s" "${OPTARG}") | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
\?) | ||
echo "Invalid option: -${OPTARG}" >&2 | ||
echo | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
export THREESCALE_DEPLOYMENT_ENV=${THREESCALE_DEPLOYMENT_ENV-production} | ||
|
||
main+=("daemon ${daemon};") | ||
main+=("worker_processes ${worker_processes};") | ||
main+=$(printenv | awk '$1 ~ /^(APICAST|THREESCALE)_/ {split($0,env,"="); print "env", env[1] ";"}') | ||
chdir $apicast; | ||
|
||
function join_by { local IFS="$1"; shift; echo "$*"; } | ||
args=$(join_by '' "${args[@]}") | ||
main=$(join_by '' "${main[@]}") | ||
$ENV{LUA_PATH} = "$apicast/src/?.lua;${lua_path}"; | ||
|
||
cd "${apicast_dir}" | ||
my @args = ('resty', "$bindir/cli", @ARGV); | ||
|
||
# shellcheck disable=SC2086 | ||
exec "${openresty_binary}" -c "${apicast_dir}/conf/nginx.conf" ${args} -g "${main} error_log ${log_file} ${log_levels[log_level]};" | ||
exec '/usr/bin/env', @args; |
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,11 @@ | ||
#!/usr/bin/env resty | ||
|
||
local ok, setup = pcall(require, 'rover.setup') | ||
|
||
if ok then | ||
setup() | ||
else | ||
package.path = './src/?.lua;' .. package.path | ||
end | ||
|
||
require('apicast.cli')(arg) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.