Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/syslog #696

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8954a1e
Adding a function to count the entities in a table
subnetmarco Oct 13, 2015
806ae78
Disabling access log for status endpoint
subnetmarco Oct 14, 2015
787b99e
Merge pull request #623 from Mashape/fix/status-logs
subnetmarco Oct 14, 2015
d26c761
Customizable DNS settings
subnetmarco Oct 15, 2015
3114ef7
Merge pull request #625 from Mashape/feat/custom-dns
subnetmarco Oct 15, 2015
731e203
fix(alf_serializer) always ensure mimeType is a string
thibaultcha Oct 15, 2015
956f94d
perf(alf_serializer) globals optimizations
thibaultcha Oct 15, 2015
eef305a
Merge pull request #626 from Mashape/fix/alf-serializer
thibaultcha Oct 15, 2015
c0ab86d
OAuth 2.0 tests to check for upstream headers
subnetmarco Oct 15, 2015
a0fc23f
Merge pull request #627 from Mashape/tests/oauth2
subnetmarco Oct 15, 2015
aa54b58
Updating dependencies
subnetmarco Oct 15, 2015
709f4b9
Merge pull request #628 from Mashape/enhancement/updating-dependencies
subnetmarco Oct 15, 2015
b912125
Merge pull request #632 from Mashape/dao/count
subnetmarco Oct 15, 2015
57b9e30
feat(cli) config validation and defaults utility
thibaultcha Oct 7, 2015
d26e179
feat(cli) use new config and dao loaders
thibaultcha Oct 7, 2015
92a37c8
Adding "total" field in API responses
subnetmarco Oct 15, 2015
21d77a5
Adding database stats into status endpoint
subnetmarco Oct 16, 2015
9f2e83a
Merge pull request #635 from Mashape/chore/api-totals
subnetmarco Oct 16, 2015
94747d8
Updating changelog for 0.6.x
subnetmarco Oct 16, 2015
15addbf
Refactoring the count function in DAO and API
subnetmarco Oct 16, 2015
d0edd94
Merge pull request #636 from Mashape/refactor/count
thibaultcha Oct 16, 2015
370f124
feat(config) commented configuration file
thibaultcha Oct 8, 2015
121a949
feat(config) add options for keyspace replication strategy
thibaultcha Sep 30, 2015
ccac50b
refactor(config) remove unnecessary dao config nesting
thibaultcha Oct 5, 2015
15e6205
feat(config) implement `enum` check for properties
thibaultcha Oct 16, 2015
303e235
feat(config) update `kong config` to new config file format
thibaultcha Oct 16, 2015
12d8171
Merge pull request #633 from Mashape/feat/commented-config
thibaultcha Oct 16, 2015
b97eef2
fix(readme): update community resources
Oct 16, 2015
fcfdc4d
Merge pull request #637 from Mashape/readme-patch
Oct 16, 2015
daa8632
Merge branch 'sinzone-patch-1' into next
thibaultcha Oct 19, 2015
99d584d
docs(readme)
sonicaghi Oct 19, 2015
50382d4
fix(config/rockspec) add missing files and remove dnsmasq_port property
thibaultcha Oct 20, 2015
f2f84fd
Merge pull request #645 from Mashape/fix/config
thibaultcha Oct 20, 2015
34fd7d8
Merge branch 'sinzone-patch-1' into next
thibaultcha Oct 20, 2015
00e5e2b
Merge branch 'master' into next
thibaultcha Oct 21, 2015
fb22f93
chore(ci) bump Cassandra version
thibaultcha Oct 21, 2015
77fd7e1
Merge pull request #649 from Mashape/chore/bump-cassandra
thibaultcha Oct 21, 2015
5163571
Merge remote-tracking branch 'mybuilder/fix-oauth2-https-check' into …
thibaultcha Oct 21, 2015
635daf0
Merge branch 'hotfix/hmac-date' into next
thibaultcha Oct 21, 2015
2bf4def
Merge branch 'release/0.5.2' into next
thibaultcha Oct 22, 2015
7595850
Merge branch 'hotfix/path-search' into next
thibaultcha Oct 22, 2015
6df7bbd
docs(ldoc) better documentation for public Lua API
thibaultcha Oct 27, 2015
e029020
Merge pull request #657 from Mashape/docs/comments
thibaultcha Oct 27, 2015
7d5420d
fix: remove erroneous inspect statement
thibaultcha Oct 27, 2015
5b6fe1f
syslog and loggly plugins
Nov 5, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ proxy_port: 8000
proxy_ssl_port: 8443
admin_api_port: 8001

## Secondary port configuration
dnsmasq_port: 8053
## DNS resolver configuration
dns_resolver:
#address: "8.8.8.8:53"
dnsmasq:
enabled: true
port: 8053

## Specify the DAO to use
database: cassandra
Expand Down
6 changes: 3 additions & 3 deletions kong/cli/utils/dnsmasq.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function _M.stop(kong_config)
end
end

function _M.start(kong_config)
function _M.start(nginx_working_dir, dnsmasq_port)
local cmd = IO.cmd_exists("dnsmasq") and "dnsmasq"

if not cmd then -- Load dnsmasq given the PATH settings
Expand All @@ -32,8 +32,8 @@ function _M.start(kong_config)
end

-- Start the dnsmasq daemon
local file_pid = kong_config.nginx_working_dir..(stringy.endswith(kong_config.nginx_working_dir, "/") and "" or "/")..constants.CLI.DNSMASQ_PID
local res, code = IO.os_execute(cmd.." -p "..kong_config.dnsmasq_port.." --pid-file="..file_pid.." -N -o")
local file_pid = nginx_working_dir..(stringy.endswith(nginx_working_dir, "/") and "" or "/")..constants.CLI.DNSMASQ_PID
local res, code = IO.os_execute(cmd.." -p "..dnsmasq_port.." --pid-file="..file_pid.." -N -o")
if code ~= 0 then
cutils.logger:error_exit(res)
else
Expand Down
25 changes: 21 additions & 4 deletions kong/cli/utils/signal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,27 @@ local function prepare_nginx_working_dir(args_config)
local ssl_cert_path, ssl_key_path = ssl.get_ssl_cert_and_key(kong_config)
local trusted_ssl_cert_path = kong_config.databases_available[kong_config.database].properties.ssl_certificate -- DAO ssl cert

-- Check dns_resolver
local dns_resolver
if kong_config.dns_resolver.address and kong_config.dns_resolver.dnsmasq.enabled then
cutils.logger:error_exit("Invalid \"dns_resolver\" setting: you cannot set both an address and enable dnsmasq")
elseif not kong_config.dns_resolver.address and not kong_config.dns_resolver.dnsmasq.enabled then
cutils.logger:error_exit("Invalid \"dns_resolver\" setting: you must set at least an address or enable dnsmasq")
elseif kong_config.dns_resolver.address then
dns_resolver = kong_config.dns_resolver.address
else
dns_resolver = "127.0.0.1:"..kong_config.dns_resolver.dnsmasq.port
end

cutils.logger:info("DNS resolver set to: "..dns_resolver)

-- Extract nginx config from kong config, replace any needed value
local nginx_config = kong_config.nginx
local nginx_inject = {
proxy_port = kong_config.proxy_port,
proxy_ssl_port = kong_config.proxy_ssl_port,
admin_api_port = kong_config.admin_api_port,
dns_resolver = "127.0.0.1:"..kong_config.dnsmasq_port,
dns_resolver = dns_resolver,
memory_cache_size = kong_config.memory_cache_size,
ssl_cert = ssl_cert_path,
ssl_key = ssl_key_path,
Expand Down Expand Up @@ -222,7 +236,7 @@ function _M.prepare_kong(args_config, signal)
kong_config.proxy_port,
kong_config.proxy_ssl_port,
kong_config.admin_api_port,
kong_config.dnsmasq_port,
kong_config.dns_resolver.dnsmasq.enabled and kong_config.dns_resolver.dnsmasq.port or "DISABLED",
kong_config.database,
tostring(dao_config)))

Expand Down Expand Up @@ -272,8 +286,11 @@ function _M.send_signal(args_config, signal)
-- dnsmasq start/stop
if signal == START then
dnsmasq.stop(kong_config)
check_port(kong_config.dnsmasq_port)
dnsmasq.start(kong_config)
if kong_config.dns_resolver.dnsmasq.enabled then
local dnsmasq_port = kong_config.dns_resolver.dnsmasq.port
check_port(dnsmasq_port)
dnsmasq.start(kong_config.nginx_working_dir, dnsmasq_port)
end
elseif signal == STOP or signal == QUIT then
dnsmasq.stop(kong_config)
end
Expand Down
44 changes: 41 additions & 3 deletions spec/integration/cli/start_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ end

describe("CLI", function()

describe("Startup plugins check", function()

setup(function()
setup(function()
os.execute("cp "..TEST_CONF.." "..SERVER_CONF)
spec_helper.add_env(SERVER_CONF)
spec_helper.prepare_db(SERVER_CONF)
Expand All @@ -31,6 +29,46 @@ describe("CLI", function()
pcall(spec_helper.stop_kong, SERVER_CONF)
end)

describe("dnsmasq check", function()

it("should start dnsmasq with the default settings", function()
local _, exit_code = spec_helper.start_kong(SERVER_CONF, true)
assert.are.same(0, exit_code)
end)

it("should not start with both dnsmasq and an address set", function()
replace_conf_property("dns_resolver", {
address = "8.8.8.8:53",
dnsmasq = {
enabled = true,
port = 8053
}
})

assert.error_matches(function()
spec_helper.start_kong(SERVER_CONF, true)
end, "Invalid \"dns_resolver\" setting: you cannot set both an address and enable dnsmasq", nil, true)
end)

it("should not start with none of dnsmasq and an address set", function()
replace_conf_property("dns_resolver", { dnsmasq = {}})

assert.error_matches(function()
spec_helper.start_kong(SERVER_CONF, true)
end, "Invalid \"dns_resolver\" setting: you must set at least an address or enable dnsmasq", nil, true)
end)

it("should start dnsmasq with a custom address", function()
replace_conf_property("dns_resolver", { address = "8.8.8.8:53", dnsmasq = { enabled = false, port = 8053}})

local _, exit_code = spec_helper.start_kong(SERVER_CONF, true)
assert.are.same(0, exit_code)
end)

end)

describe("Startup plugins check", function()

it("should start with the default configuration", function()
assert.has_no.errors(function()
spec_helper.start_kong(TEST_CONF, true)
Expand Down
8 changes: 6 additions & 2 deletions spec/unit/statics_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ proxy_port: 8000
proxy_ssl_port: 8443
admin_api_port: 8001

## Secondary port configuration
dnsmasq_port: 8053
## DNS resolver configuration
dns_resolver:
#address: "8.8.8.8:53"
dnsmasq:
enabled: true
port: 8053

## Specify the DAO to use
database: cassandra
Expand Down