-
Notifications
You must be signed in to change notification settings - Fork 650
postgresql-style pre-startup init scripts hook #53
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
gosu mongodb "$@" --fork --bind_ip 127.0.0.1
? That way it is only available inside the container and we keep numa or any passed in flags.I'm not sure if
--syslog
or--logpath /dev/stdout
should be added, since one is required when using--fork
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the postgres image they don't take the
$@
args when starting the temporary server... I'm not sure what the reasoning to or not to is. I think the only really important thing is that you're using the same data dir as the real server will be using.I think maybe
--logpath /dev/stdout
would be best... all the logs are supposed to go there under docker, the main server ones will do, so it would be the same.I'm happy with whatever you'd advise in both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The datadir of
/data/db
is automatic (docs.mongodb).We actually need to adjust this, postgres, and the other SQLs to start with passed in options, so that users could override things like
datadir
or run with--storageEngine=wiredTiger
. I don't think using/dev/stdout
for logpath will work, since that stdout won't be the same stdout as the bash process running it. We might as well just stick it in/var/log/mongodb/
.The other option is to drop
--fork
and--logpath
and just background it with&
and stick in a "try to connect" loop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little more playing with this, and the following works successfully: (from tianon/gosu#8 (comment))
The main issue still remaining is that as written, this code will re-run on every startup of MongoDB, so we need a reasonably non-hacky way to determine whether a database has already been initialized. In the PostgreSQL image, we check for a specific file that Postgres itself always creates. In the MySQL image, we took a check from upstream which checks for a
mysql
database within the configured/data/db
folder.In the case of this image, we're even slightly more complicated because
--datadir
might be passed on the command line, and we need to be able to handle that intelligently (and it might be hidden behind-f
in a config file too), so I think this might be layering hacks deeper and deeper. 😞 😢There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't realise postgres only ran it once, I'd assumed the startup script should be idempotent and it wouldn't matter if it ran every time