diff --git a/kong/cli/restart.lua b/kong/cli/restart.lua index 578668018f73..9e96cb13b007 100644 --- a/kong/cli/restart.lua +++ b/kong/cli/restart.lua @@ -28,3 +28,4 @@ if not signal.send_signal(args.config) then end cutils.logger:success("Restarted") +cutils.logger:syslog("Restarted") diff --git a/kong/cli/start.lua b/kong/cli/start.lua index eabbb601fa68..5ad3b2129b8b 100755 --- a/kong/cli/start.lua +++ b/kong/cli/start.lua @@ -22,6 +22,7 @@ signal.prepare_kong(args.config) if signal.send_signal(args.config) then cutils.logger:success("Started") + cutils.logger:syslog("Started") else cutils.logger:error_exit("Could not start Kong") end diff --git a/kong/cli/utils/signal.lua b/kong/cli/utils/signal.lua index 4a40f777a3b8..53e134f85018 100644 --- a/kong/cli/utils/signal.lua +++ b/kong/cli/utils/signal.lua @@ -11,8 +11,6 @@ local kong_config_path local kong_config local dao_factory -local KONG_SYSLOG = "kong-hf.mashape.com" - -- Retrieve the desired Kong config file, parse it and provides a DAO factory -- Will cache them for future retrieval -- @param args_config Path to the desired configuration (usually from the --config CLI argument) @@ -109,8 +107,8 @@ local function prepare_nginx_working_dir(args_config) if kong_config.send_anonymous_reports then -- If there is no internet connection, disable this feature local socket = require "socket" - if socket.dns.toip(KONG_SYSLOG) then - nginx_config = "error_log syslog:server="..KONG_SYSLOG..":61828 error;\n"..nginx_config + if socket.dns.toip(constants.SYSLOG.ADDRESS) then + nginx_config = "error_log syslog:server="..constants.SYSLOG.ADDRESS..":"..tostring(constants.SYSLOG.PORT).." error;\n"..nginx_config else cutils.logger:warn("The internet connection might not be available, cannot resolve "..KONG_SYSLOG) end diff --git a/kong/cli/utils/utils.lua b/kong/cli/utils/utils.lua index a9367659320c..9262af7f7496 100644 --- a/kong/cli/utils/utils.lua +++ b/kong/cli/utils/utils.lua @@ -62,6 +62,10 @@ function Logger:error_exit(str) os.exit(1) end +function Logger:syslog(str) + IO.os_execute("nc -w0 -u "..constants.SYSLOG.ADDRESS.." "..tostring(constants.SYSLOG.PORT).." <<< \"<14>"..str.."\"") +end + local logger = Logger() -- diff --git a/kong/constants.lua b/kong/constants.lua index 1155f6835795..6a9c82c5edb6 100644 --- a/kong/constants.lua +++ b/kong/constants.lua @@ -1,6 +1,10 @@ return { NAME = "kong", VERSION = "0.2.0-1", + SYSLOG = { + ADDRESS = "kong-hf.mashape.com", + PORT = 61828 + }, CLI = { GLOBAL_KONG_CONF = "/etc/kong/kong.yml", NGINX_CONFIG = "nginx.conf", diff --git a/package-build.sh b/package-build.sh index 9148e13bc5a3..b0654ee85019 100755 --- a/package-build.sh +++ b/package-build.sh @@ -72,6 +72,7 @@ elif hash yum 2>/dev/null; then PACKAGE_TYPE="rpm" LUA_MAKE="linux" + FPM_PARAMS="-d nc" elif hash apt-get 2>/dev/null; then if [[ $EUID -eq 0 ]]; then # If already root, install sudo just in case (Docker) @@ -81,6 +82,7 @@ elif hash apt-get 2>/dev/null; then PACKAGE_TYPE="deb" LUA_MAKE="linux" + FPM_PARAMS="-d netcat" else echo "Unsupported platform" exit 1