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
chore(windows-client): proof of concept for installing a system service with WiX #4903
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Terraform Cloud Plan Output
|
Performance Test ResultsTCP
UDP
|
I'm going to want a well-known dir that the Windows IPC service writes logs to, and that the Windows GUI can pick them up from. I don't know how I did this for Linux last week, but it should probably be in here too.
…one into chore/windows-service-poc
@@ -39,7 +39,7 @@ Best performed on a clean VM | |||
1. Export the logs | |||
1. Expect the zip file to start with "firezone_logs_" | |||
1. Expect `zipinfo` to show a single directory in the root of the zip, to prevent zip bombing | |||
1. Expect two subdirectories in the zip, "connlib", and "app", each with 3 files, totalling 6 files | |||
1. Expect two subdirectories in the zip, "connlib", and "app", with 3 and 2 files respectively, totalling 5 files |
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'm not sure why this had 6 files before. I have two hypotheses:
- I had been clicking on the notification to test the single-instance behavior, that could create a 3rd log file
- Maybe the deep link used to write a log file and stopped recently
The 5 files should be correct now though:
- The IPC service runs when it's first installed
- After you reboot, the IPC service runs again
- Then the GUI runs
- Then there's another reboot, and the IPC service runs again
- Then the GUI runs again
A 6th file would have to come from somewhere odd.
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.
Left a few comments, nothing major but is there an issue corresponding to this PR? I'm not familiar with what WiX is
let (layer, _handle) = cli.log_dir.as_deref().map(file_logger::layer).unzip(); | ||
setup_global_subscriber(layer); | ||
tracing::info!(git_version = crate::GIT_VERSION); | ||
|
||
if !nix::unistd::getuid().is_root() { | ||
anyhow::bail!("This is the IPC service binary, it's not meant to run interactively."); | ||
} | ||
run_ipc_service(cli) | ||
let rt = tokio::runtime::Runtime::new()?; | ||
let (_shutdown_tx, shutdown_rx) = mpsc::channel(1); |
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.
this channel doesn't seem to be used anywhere
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.
Yeah, it's only there to match the signature of the Windows implementation. On Windows it signals from the main thread (which handles requests from the Windows service controller) to the service function (which Windows forces to run in a worker thread) telling our service function to exit.
There is probably a way to move the caller into the platform-specific files, or replace the shutdown channel with a poll function, but I'm not sure how to do it from here.
ServiceControl::SessionChange(_) => ServiceControlHandlerResult::NotImplemented, | ||
ServiceControl::TimeChange => ServiceControlHandlerResult::NotImplemented, | ||
ServiceControl::TriggerEvent => ServiceControlHandlerResult::NotImplemented, | ||
_ => todo!(), |
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.
Can we just match all the above here with NotImplemented
?
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.
Yep. The enum is non-exhaustive so I had to keep the _
and stick the others together with |
. Otherwise it would run afoul of the linter.
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.
but we could just remove all the previous NotImplemented
matches and just match _ => NotImplemented
shutdown_rx: mpsc::Receiver<()>, | ||
) -> Result<()> { | ||
tracing::info!("run_ipc_service"); | ||
rt.block_on(async { ipc_listen(cli, shutdown_rx).await }) |
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.
can we move shutdown_rx.recv().await
here?
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.
Maybe. I did it this way to match the Linux impl, but actually in both cases I could inline the async fn into an async block. All that this does is wrap block_on
and save one layer of indentation.
@conectado Yes, the related issue is #4899. I couldn't find a way to make Windows automatically delete the DNS rules when we exit, and this was causing problems when the system reboots. By running this background service, we can just clear our own rules on boot. And we'll need the service soon anyway for #3712 |
And WiX is a toolkit from Microsoft that uses an XML schema to generate MSI installers. Tauri uses it internally, so I took it apart a little bit to add our background service. https://wixtoolset.org/docs/v3/ |
oh so this service would only delete our NRPT rules? |
@conectado Yeah #4918 builds on this to delete the NRPT rules, and that'll close #4899. |
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.
LGTM
Before merging
Clean up function names