Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
39.22k stars 4.81k forks source link

Change "kong start" behavior when Kong is already running #609

Closed scottefein closed 9 years ago

scottefein commented 9 years ago

kong/kong/cli/start.lua Currently it does the following:

if running then
  cutils.logger:error_exit("Could not start Kong because it is already running")
end

However it seems like this is unexpected behavior. Instead shouldn't it just exit with a warning? I'm running into this as an issue when I "kong start" in puppet (errors if it's already up). Instead I'm forced to switch to using "kong restart". This is fine (as in it works) but not ideal.

Happy to make a pull request to change this...

subnetmarco commented 9 years ago

Instead shouldn't it just exit with a warning?

You mean with a 0 status code, instead of 1?

scottefein commented 9 years ago

Yup, with status code 0.

On Mon, Oct 12, 2015 at 7:38 PM, Marco Palladino notifications@github.com wrote:

Instead shouldn't it just exit with a warning?

You mean with a 0 status code, instead of 1?

— Reply to this email directly or view it on GitHub https://github.com/Mashape/kong/issues/609#issuecomment-147549418.

subnetmarco commented 9 years ago

Kong's behavior in this case is exactly the same as nginx. When nginx is being started again, but for some reason it cannot start because it's already running, it will return an error message with status 1:

$ /usr/local/openresty/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()
$ echo $?
1
scottefein commented 9 years ago

I suppose what Kong really needs is a service script to handle this then. If NGINX operates the same way then it makes sense to leave it. Thanks! Closing.