Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

lorri daemon #81

Merged
merged 43 commits into from
Jun 20, 2019
Merged

lorri daemon #81

merged 43 commits into from
Jun 20, 2019

Conversation

Profpatsch
Copy link
Collaborator

Implements a lorri daemon command listening on a unix socket and a lorri ping command to send a build job to the daemon.

The test is still WIP, blocking on some action.

There’s still a few TODOs left, which will be addressed in a successive PR.

@Profpatsch Profpatsch requested a review from grahamc May 14, 2019 16:47
@Profpatsch Profpatsch force-pushed the message-over-socket branch from f95f17c to 42aa124 Compare May 15, 2019 16:49
@Profpatsch Profpatsch changed the title WIP lorri daemon lorri daemon May 15, 2019
@Profpatsch
Copy link
Collaborator Author

Okay, the test should now work.

@Profpatsch Profpatsch force-pushed the message-over-socket branch from 42aa124 to a54f395 Compare May 15, 2019 16:58
nix/pre-check.sh Outdated Show resolved Hide resolved
@Profpatsch Profpatsch force-pushed the message-over-socket branch 4 times, most recently from 2b3a744 to d7187cc Compare May 22, 2019 16:52
@Profpatsch Profpatsch force-pushed the message-over-socket branch from 0476708 to dcc55ab Compare May 27, 2019 16:41
@Profpatsch
Copy link
Collaborator Author

Heck! It’s green!

@Profpatsch Profpatsch requested a review from grahamc May 27, 2019 17:38
@Profpatsch
Copy link
Collaborator Author

Btw, I’m not sure whether we really need the dependency on nix just to get access to the poll function. It’s a very, very thin wrapper around https://docs.rs/crate/libc/0.2.55, so might be best to just copy that one function over.

Copy link
Contributor

@grahamc grahamc left a comment

Choose a reason for hiding this comment

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

Looks like there are a lot of TODOs to be done. I think it'd be good to get those done prior to a thorough review?

@Profpatsch
Copy link
Collaborator Author

I want to get this PR merged, it’s been open for too long.

Since I documented every TODO in the comments, we can fix them in separate PRs.

@grahamc
Copy link
Contributor

grahamc commented May 28, 2019

Getting the existing TODOs todone won't be a substantial lift, and when possible, it is always better to get it done before integration. Let's do it in this PR.

@Profpatsch Profpatsch force-pushed the message-over-socket branch 2 times, most recently from b94bf20 to 31aae02 Compare May 29, 2019 18:27
@Profpatsch Profpatsch force-pushed the message-over-socket branch 5 times, most recently from 69c2e5f to a672eba Compare June 7, 2019 22:26
@shlevy
Copy link

shlevy commented Jun 15, 2019

Anything we're waiting on here?

Copy link
Contributor

@grahamc grahamc left a comment

Choose a reason for hiding this comment

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

Code review done, giving it a go

src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
src/cli.rs Outdated Show resolved Hide resolved
src/socket/mod.rs Show resolved Hide resolved
src/socket/mod.rs Show resolved Hide resolved
src/socket/mod.rs Show resolved Hide resolved
src/socket/mod.rs Show resolved Hide resolved
}

/// Wrap a socket with a timeout. Inspired by https://docs.rs/crate/timeout-readwrite/0.2.0/.
mod timeout {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love the code in this module, it feels quite complex and I don't really want to "own" it.

Copy link
Collaborator Author

@Profpatsch Profpatsch Jun 19, 2019

Choose a reason for hiding this comment

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

It’s sadly the only thing to not break the Darwin socket implementation in non-debuggable ways. Just setting the socket timeout option worked fine on Linux, but not on Darwin. It’s just a small wrapper around the poll(2) syscall, nothing extremely complex or error-prone.

src/main.rs Outdated Show resolved Hide resolved
@Profpatsch Profpatsch force-pushed the message-over-socket branch from a1d5415 to 07eac0d Compare June 19, 2019 14:51
Profpatsch and others added 25 commits June 20, 2019 18:46
This way we keep all project-wide constant setup in one place.
Creates a dedicated directory for GC roots, because we need a
collision-free space for our socket files in the toplevel directory.
We can watch an arbitrary nix file. The rest of the codebase already
uses `nix_file`, so rename for consistency.
The `id` function hashed the full path and the name. The latter was
completely determined by the full path, so name is redundant.

When we want to allow any nix file, we cannot determine name
anyway (without it panicking for some file paths).
lorri cannot have a sensible concept of a project directory. Builders
need only a valid nix file to function.

We can still expose the convenience that `shell.nix` is automatically
discovered and used as the default nix file, even without explicitely
tracking the parent directory of that shell file.
Slight refactoring of `main()` is necessary to correctly set up the
roots.
Projects are just a trivial wrapper around a nix file path and gc_root
directory, so we don’t need to actually clone that info.
After the client opens a connection, the server won’t wait forever for
a message to free its resouces.
The daemon gets the files to evaluate over the socket instead of from
`shell.nix` on startup.
Internal & experimental commands should be differentiable from
user-commands.
@Profpatsch Profpatsch force-pushed the message-over-socket branch from 1fdd65d to 40dc0d3 Compare June 20, 2019 17:10
@Profpatsch Profpatsch merged commit 2b9c420 into master Jun 20, 2019
@grahamc grahamc deleted the message-over-socket branch June 21, 2019 09:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants