Skip to content

Commit

Permalink
wip/feat: new commands for cli refactor
Browse files Browse the repository at this point in the history
- 'config' replaces scripts/config.lua
- 'version'
- use ansicolors instead of custom utils
- cli utils functions and constants
  • Loading branch information
thibaultcha committed Mar 23, 2015
1 parent a15b798 commit 853d676
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 366 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
KONG_HOME = `pwd`
TESTING_CONF = kong_TEST.yml
DEVELOPMENT_CONF = kong_DEVELOPMENT.yml

Expand All @@ -15,15 +14,15 @@ install:

dev:
@scripts/dev_rocks.sh
@scripts/config.lua -k $(KONG_HOME) -e TEST create
@scripts/config.lua -k $(KONG_HOME) -e DEVELOPMENT create
@bin/kong config -e TEST
@bin/kong config -e DEVELOPMENT
@scripts/db.lua -c $(DEVELOPMENT_CONF) migrate

clean:
@rm -f luacov.*
@scripts/db.lua -c $(DEVELOPMENT_CONF) reset
@rm -f $(DEVELOPMENT_CONF) $(TESTING_CONF)
@rm -rf nginx_tmp
@scripts/db.lua -c $(DEVELOPMENT_CONF) reset

run:
@bin/kong -c $(DEVELOPMENT_CONF) start
Expand Down
9 changes: 6 additions & 3 deletions bin/kong
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env lua

local help_message = [[
local utils = require "kong.cmd.utils"
local infos = utils.get_infos()
local help_message = string.format([[
Usage: kong <command>
where <command> is one of:
start, stop, version
start, stop, config, db, version
kong --help print this message
kong <command> --help print the help message of a command
[email protected]]]
%s@%s]], infos.name, infos.version)

local cmd = arg[1]

Expand All @@ -19,4 +21,5 @@ if not cmd or cmd == "-h" or cmd == "--help" then
os.exit(0)
end

-- TODO: test if command exists
require("kong.cmd."..cmd)
176 changes: 0 additions & 176 deletions bin/kong.sh

This file was deleted.

9 changes: 8 additions & 1 deletion kong-0.0.1beta-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = {
"inspect ~> 3.0-1",
"luasocket ~> 2.0.2-5",
"lua-llthreads2 ~> 0.1.3-1",
"ansicolors ~> 1.0.2-3",
"lua_cliargs ~> 2.3-3",
"lua-path ~> 0.2.3-1",
"luatz ~> 0.3-1"
Expand All @@ -43,8 +44,11 @@ build = {

["kong.constants"] = "src/constants.lua",

["kong.cmd.utils"] = "src/cmd/utils.lua",
["kong.cmd.start"] = "src/cmd/start.lua",
["kong.cmd.stop"] = "src/cmd/stop.lua",
["kong.cmd.config"] = "src/cmd/config.lua",
["kong.cmd.version"] = "src/cmd/version.lua",

["kong.tools.utils"] = "src/tools/utils.lua",
["kong.tools.timestamp"] = "src/tools/timestamp.lua",
Expand All @@ -67,6 +71,8 @@ build = {
["kong.dao.cassandra.accounts"] = "src/dao/cassandra/accounts.lua",
["kong.dao.cassandra.applications"] = "src/dao/cassandra/applications.lua",

["kong.plugins.base_plugin"] = "src/plugins/base_plugin.lua",

["kong.plugins.basicauth.handler"] = "src/plugins/basicauth/handler.lua",
["kong.plugins.basicauth.access"] = "src/plugins/basicauth/access.lua",
["kong.plugins.basicauth.schema"] = "src/plugins/basicauth/schema.lua",
Expand Down Expand Up @@ -96,13 +102,14 @@ build = {
["kong.plugins.ratelimiting.schema"] = "src/plugins/ratelimiting/schema.lua",

["kong.web.app"] = "src/web/app.lua",
["kong.web.routes.accounts"] = "src/web/routes/accounts.lua",
["kong.web.routes.apis"] = "src/web/routes/apis.lua",
["kong.web.routes.accounts"] = "src/web/routes/accounts.lua",
["kong.web.routes.applications"] = "src/web/routes/applications.lua",
["kong.web.routes.plugins"] = "src/web/routes/plugins.lua",
["kong.web.routes.base_controller"] = "src/web/routes/base_controller.lua"
},
install = {
conf = { "kong.yml" },
bin = { "bin/kong" }
},
copy_directories = { "src/web/admin", "src/web/static" }
Expand Down
7 changes: 3 additions & 4 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ plugins_available:
- udplog
- filelog

# Uncomment the following line to setup a custom output directory
# output: /var/log/kong
# Nginx prefix path directory
nginx_working_dir: /usr/local/kong/

# Specify the DAO to use
database: cassandra
Expand All @@ -29,14 +29,13 @@ send_anonymous_reports: true

# Cache configuration
cache:
expiration: 5 # In seconds
expiration: 5 # in seconds

nginx: |
worker_processes auto;
error_log logs/error.log info;
worker_rlimit_nofile 84280;
daemon on;
pid nginx.pid;
env KONG_CONF;
env KONG_HOME;
Expand Down
66 changes: 0 additions & 66 deletions scripts/config.lua

This file was deleted.

Loading

0 comments on commit 853d676

Please sign in to comment.