Skip to content

Fix entrypoint script loadmodule twice#85

Open
hieu2102 wants to merge 4 commits intovalkey-io:mainlinefrom
hieu2102:fix-entrypoint-script-loadmodule-twice
Open

Fix entrypoint script loadmodule twice#85
hieu2102 wants to merge 4 commits intovalkey-io:mainlinefrom
hieu2102:fix-entrypoint-script-loadmodule-twice

Conversation

@hieu2102
Copy link
Contributor

@hieu2102 hieu2102 commented Feb 5, 2026

Updated PR from #82, added a check to prevent grep print error grep: : No such file or directory if no config file is used
Original PR description:
If valkey container is started with a config file, the current bundle-docker-entrypoint.sh script will still generate the valkey-server command with --loadmodule flag.
If a CONFIG REWRITE is issued (for example, by a Sentinel client), the loadmodule entries will be written to the config file. Restarting the container will result in a module initialization error (because modules are loaded twice).

This PR adds a check to skip the --loadmodule flag if the container is started with a config file, and the loadmodule $module entry is already present.

…sent in config file

Signed-off-by: hieu2102 <hieund2102@gmail.com>
…s list

Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
Signed-off-by: hieu2102 <hieund2102@gmail.com>
@hieu2102 hieu2102 marked this pull request as ready for review February 5, 2026 02:55
# Auto-discover and append all .so modules in MODULE_DIR
for module in "$MODULE_DIR"/*.so; do
if [ -n "$(grep "loadmodule $module" "${CONFIG}")" ]; then
if [ "${CONFIG}" != "" ] && [ -n "$(grep "loadmodule $module" "${CONFIG}")" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Will this handle different path of the module?
like config file has a different path than the one used by bundle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roshkhatri it won't, if there are two different paths, then the container will fail to start.
It will also fail if you explicitly loadmodule when the .so file name is different (I guess it is for use cases where you want to use a specific version of the module?).

My purpose for this PR is just to prevent the container from failing to start after running CONFIG REWRITE. If we want comprehensive checks, then I guess it makes more sense to implement it in Valkey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants