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 issue with instances sharing config dir. #63

Closed
wants to merge 1 commit into from

Conversation

efarrer
Copy link
Contributor

@efarrer efarrer commented Oct 4, 2023

Incorporate the --name into the state directory so that multiple instances will have unique state directories.

Fixes: #62

Incorporate the --name into the state directory so that multiple
instances will have unique state directories.

Fixes: boinkor-net#62
@antifuchs
Copy link
Collaborator

Hrm, I've been thinking about this change a bunch over the past days and I don't think it's quite right: Merging it will break all (my) installations where I pass a -stateDir that is already in the correct path... and all usages of the nixos config (which uses systemd's $STATE_DIRECTORY env variable, which is already per-service).

I think a slightly more compatible solution (which would still fulfill the ideas behind #62) would be to drop a file stating the tsnsrv instance's name into the state directory (using one of the plenty lockfile libraries, I think) - if another instance was run from that state directory with a different name, that state dir can not be used & this instance can exit with an error.

How does that sound?

@efarrer
Copy link
Contributor Author

efarrer commented Oct 11, 2023

Hrm, I've been thinking about this change a bunch over the past days and I don't think it's quite right: Merging it will break all (my) installations where I pass a -stateDir that is already in the correct path... and all usages of the nixos config (which uses systemd's $STATE_DIRECTORY env variable, which is already per-service).

I think a slightly more compatible solution (which would still fulfill the ideas behind #62) would be to drop a file stating the tsnsrv instance's name into the state directory (using one of the plenty lockfile libraries, I think) - if another instance was run from that state directory with a different name, that state dir can not be used & this instance can exit with an error.

How does that sound?

This implementation checks the value of s.stateDir and only changes the behavior if the s.stateDir == "". So I don't think it will break backwards compatibility with installations that pass -stateDir or set the $STATE_DIRECTORY env variable. However, it does break backwards compatibility in the cases where a user has run a single instance on a machine without passing -stateDir or setting $STATE_DIRECTORY. I think I can use your suggestion to fix this backwards incompatibility and create a completely backwards compatible solution. Your comment has also made me realize that the business logic behind this is complex enough that it warrants some unit tests to document the behavior. I'll create a more robust solution and create a new pull request.

@efarrer
Copy link
Contributor Author

efarrer commented Oct 11, 2023

Closing and will create a better solution.

@efarrer efarrer closed this Oct 11, 2023
@efarrer efarrer deleted the config-dir branch October 18, 2023 02:11
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.

Brittle behavior when starting subsequent tsnsrv instances.
2 participants