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

Working directory checks on startup #939

Merged
merged 1 commit into from
Feb 6, 2016
Merged

Conversation

subnetmarco
Copy link
Member

This PR adds the following checks to the Kong startup logic:

  • Check if the working directory exists. If it doesn't it tries to create it and set the right permissions
  • Checks if the working directory is a real directory, and not a file
  • Checks if the working directory has write, read and executable permissions to the user that's currently running Kong (executable permissions required by the Serf even handler).

On a side note nginx_working_dir should be renamed in the future to working_dir or kong_working_dir since it's not specific to nginx anymore.

if exit_code ~= 0 then
return false, "Cannot create the working directory at "..working_dir
else
local _, exit_code = IO.os_execute("chmod -R +wr "..working_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing that I don't really like in this PR. It is kinda overriding the user's umask setting, which should be preserved. Ok for checking the permissions before booting, not so ok to mess up with a user's settings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have other options. Kong will not work if +wr is not set on the folder.

@subnetmarco subnetmarco added pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release) and removed pr/status/needs review labels Feb 5, 2016
subnetmarco added a commit that referenced this pull request Feb 6, 2016
Working directory checks on startup
@subnetmarco subnetmarco merged commit ab67bd2 into next Feb 6, 2016
@subnetmarco subnetmarco deleted the chore/check-working-dir branch February 6, 2016 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/ready (but hold merge) No more concerns, but do not merge yet (probably a conflict of interest with another PR or release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants