feat(scheduler): allow a custom command for scheduled tasks - #540
Open
xchacha20-poly1305 wants to merge 2 commits into
Open
feat(scheduler): allow a custom command for scheduled tasks#540xchacha20-poly1305 wants to merge 2 commits into
xchacha20-poly1305 wants to merge 2 commits into
Conversation
Collaborator
|
can you fix the ci ? |
Every backend resolved the program to wake up from ProcessHandle.current().info().command(), so apps that bootstrap through a custom launcher had the OS start the JVM/native binary instead of the launcher, with no way to override it. SchedulerConfig now exposes executablePath and executableArguments, mirroring AutoLaunchConfig. The scheduled invocation becomes `<executablePath> <executableArguments…> --nucleus-scheduler-run <taskId>`; leaving both unset keeps the previous behavior. The new internal SchedulerExecutable resolves the command for all three backends and centralizes the scheduler flag on DesktopBootReceiver, replacing the three duplicated executablePath getters and two copies of the constant. Wrapper-script content generation is split from file writing so it can be unit-tested, and while threading the arguments through: Linux script values are single-quote escaped instead of naively wrapped in double quotes, Windows arguments containing spaces are quoted, and macOS plist <string> values are XML-escaped. Closes NucleusFramework#498 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SchedulerExecutableTest pins the resolution order (config override, blank override ignored, ProcessHandle fallback) and the argument ordering. TaskWrapperScriptTest asserts the generated Linux and Windows wrappers invoke the configured launcher with its extra arguments ahead of the scheduler flag, escape quotes and spaces, and still self-destruct when the executable is gone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
xchacha20-poly1305
force-pushed
the
custom-scheduler
branch
from
August 18, 2026 09:58
78a1c53 to
416d13c
Compare
Author
The test all passed on my machine. Can you re-run it? My change isn't relevant to decorated-window-tao. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #498
Problem
All three scheduler backends resolved the program the OS should wake up from
ProcessHandle.current().info().command(). Apps that bootstrap through a custom launcher therefore had the OS start the JVM/native binary rather than the launcher, and there was no way to override it.Solution
SchedulerConfig(new, modelled on the existingAutoLaunchConfig):The scheduled invocation becomes
<executablePath> <executableArguments…> --nucleus-scheduler-run <taskId>. Leaving both unset keeps today's behavior exactly, so this is additive — no API break.Implementation notes
internal object SchedulerExecutableresolves the command for all three backends and centralizes the scheduler flag onDesktopBootReceiver.SCHEDULER_ARG, replacing the three duplicatedexecutablePathgetters and two copies of the constant.LinuxSystemdScheduler,MacOSLaunchdScheduler(native + shell plist, and both retry paths) andWindowsTaskScheduler(wscript wrapper + retry fallback).TaskWrapperScriptgained anexecArgsparameter, and content generation is split from file writing (buildLinuxScript/buildWindowsScript) so the generated scripts are unit-testable."…", Windows arguments containing spaces are quoted, and macOS plist<string>values are XML-escaped (they were interpolated raw before).SchedulerConfigKDoc.Testing
:scheduler:test :scheduler:apiCheck :scheduler:detekt :scheduler:ktlintCheck :scheduler-testing:testpass;scheduler/api/scheduler.apire-dumped.SchedulerExecutableTest(resolution order, blank override ignored, argument ordering) andTaskWrapperScriptTest(Linux/Windows wrapper content, escaping, self-destruct branch).launcher --background "--log dir" --nucleus-scheduler-run syncwith the space-containing argument preserved as one argument; deleting the launcher made the script correctly unregister and delete itself.