Skip to content

Commit

Permalink
Rename out/ to nginx_tmp/
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Mar 4, 2015
1 parent faadb2c commit 3f6822c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node_modules/
bower_components/

# kong
out/
nginx_tmp/
kong*.yml

# luacov
Expand Down
2 changes: 1 addition & 1 deletion .travis/setup_cassandra.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

CASSANDRA_BASE=apache-cassandra-$CASSANDRA

Expand Down
2 changes: 1 addition & 1 deletion .travis/setup_lua.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

# A script for setting up environment for travis-ci testing.
# Sets up Lua and Luarocks.
Expand Down
2 changes: 1 addition & 1 deletion .travis/setup_openresty.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

OPENRESTY_BASE=ngx_openresty-$OPENRESTY

Expand Down
13 changes: 7 additions & 6 deletions bin/kong
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export KONG_HOME="$(echo $SCRIPT_DIR | sed -e 's/\/[^\/]*$//')"

# Properties
export KONG_CONF=$KONG_HOME/kong.yml
PID=$KONG_HOME/out/nginx.pid
NGINX_TMP=$KONG_HOME/nginx_tmp
PID=$NGINX_TMP/nginx.pid

######################
# Utility function #
Expand Down Expand Up @@ -57,11 +58,11 @@ function show_version {
function start {
printf "Starting Kong"

mkdir -p $KONG_HOME/out/logs
touch $KONG_HOME/out/logs/error.log
touch $KONG_HOME/out/logs/access.log
$KONG_HOME/scripts/config.lua -c $KONG_CONF -o $KONG_HOME/out/ nginx
nginx -p $KONG_HOME/out -c $KONG_HOME/out/nginx.conf
mkdir -p $NGINX_TMP/logs
touch $NGINX_TMP/logs/error.log
touch $NGINX_TMP/logs/access.log
$KONG_HOME/scripts/config.lua -c $KONG_CONF -o $NGINX_TMP nginx
nginx -p $NGINX_TMP -c $NGINX_TMP/nginx.conf

if [ $? -eq 0 ]; then
printf "$(tput setaf 2) [OK]\n$(tput sgr 0)"
Expand Down
27 changes: 13 additions & 14 deletions scripts/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,30 @@ local yaml = require "yaml"
local utils = require "kong.tools.utils"

cli:set_name("config.lua")
cli:add_argument("COMMAND", "<create|nginx>")
cli:add_option("-c, --config=CONFIG", "path to config", "kong.yml")
cli:add_option("-o, --output=OUTPUT", "path to output file", ".")
cli:add_option("-k, --kong=KONG_HOME", "", ".")
cli:add_option("-e, --env=ENV", "environment", "")
cli:add_argument("COMMAND", "{create|nginx}")
cli:add_option("-c, --config=CONFIG", "config file", "kong.yml")
cli:add_option("-o, --output=OUTPUT", "output file (for create)", ".")
cli:add_option("-k, --kong=KONG_HOME", "KONG_HOME (where Kong is installed)", ".")
cli:add_option("-e, --env=ENV", "environment name (for create)", "")

-- Args parsing and defaults
local args = cli:parse(arg)
if not args then
os.exit(1)
end

local KONG_CONFIG_FILENAME = string.format("kong%s.yml", args.env ~= "" and "_"..args.env or "")
local CONFIG_FILENAME = string.format("kong%s.yml", args.env ~= "" and "_"..args.env or "")
local config_content = utils.read_file(args.config)
local config = yaml.load(config_content)

if args.COMMAND == "create" then

local default_env_values = {
test = {
local DEFAULT_ENV_VALUES = {
TEST = {
["keyspace: kong"] = "keyspace: kong_tests",
["lua_package_path \";;\""] = "lua_package_path \""..args.kong.."/src/?.lua;;\"",
["error_log logs/error.log info"] = "error_log logs/error.log debug"
},
development = {
DEVELOPMENT = {
["keyspace: kong"] = "keyspace: kong_development",
["lua_package_path \";;\""] = "lua_package_path \""..args.kong.."/src/?.lua;;\"",
["error_log logs/error.log info"] = "error_log logs/error.log debug",
Expand All @@ -40,14 +39,14 @@ if args.COMMAND == "create" then
}

-- Create a new default kong config for given environment
if default_env_values[args.env:lower()] then
-- Known environment with variables we can override
for k, v in pairs(default_env_values[args.env:lower()]) do
if DEFAULT_ENV_VALUES[args.env:upper()] then
-- If we know the environment we can override some of the variables
for k, v in pairs(DEFAULT_ENV_VALUES[args.env:upper()]) do
config_content = config_content:gsub(k, v)
end
end

utils.write_to_file(path:join(args.output, KONG_CONFIG_FILENAME), config_content)
utils.write_to_file(path:join(args.output, CONFIG_FILENAME), config_content)

elseif args.COMMAND == "nginx" then

Expand Down

0 comments on commit 3f6822c

Please sign in to comment.