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

fix: redis should listen on unix socket when port is 0 #1378

Merged
merged 3 commits into from
Aug 11, 2024

Conversation

frectonz
Copy link
Contributor

Fixes #1068

This PR configures the redis service to listen on a unix socket when the specified port is 0. The socket file will be stored in DEVENV_RUNTIME. A new environment variable REDIS_UNIX_SOCKET will also be injected into the environment. It points to the socket file, so that users can easily connect to to the service like this.

redis-cli -s $REDIS_UNIX_SOCKET

devenv is the main tool that got me introduced to the nix world, it is a really useful tool, thanks for making it.

@domenkozar
Copy link
Member

Looks great! Can you move the test into tests?

@frectonz
Copy link
Contributor Author

I have moved it and devenv-run-tests --only redis-socket tests succeeds on my machine.

@@ -67,14 +74,15 @@ in
cfg.package
];

env.REDIS_UNIX_SOCKET = REDIS_UNIX_SOCKET;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should set this on non-zero port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right. It is only needed when port is zero.

I don't know what the right way to conditionally set an environment variable would be, would this work.

env.REDIS_UNIX_SOCKET = if cfg.port == 0 then REDIS_UNIX_SOCKET else null;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with optionalAttrs instead of setting it to null.

@frectonz
Copy link
Contributor Author

frectonz commented Aug 11, 2024

I don't think the failing tests are related to my changes, am i wrong?

@domenkozar domenkozar merged commit e310d0b into cachix:main Aug 11, 2024
267 of 275 checks passed
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.

Redis service should listen on unix socket when port = 0
2 participants