Jobbr.Runtime.ForkedExecution
3.0.4
dotnet add package Jobbr.Runtime.ForkedExecution --version 3.0.4
NuGet\Install-Package Jobbr.Runtime.ForkedExecution -Version 3.0.4
<PackageReference Include="Jobbr.Runtime.ForkedExecution" Version="3.0.4" />
<PackageVersion Include="Jobbr.Runtime.ForkedExecution" Version="3.0.4" />
<PackageReference Include="Jobbr.Runtime.ForkedExecution" />
paket add Jobbr.Runtime.ForkedExecution --version 3.0.4
#r "nuget: Jobbr.Runtime.ForkedExecution, 3.0.4"
#:package Jobbr.Runtime.ForkedExecution@3.0.4
#addin nuget:?package=Jobbr.Runtime.ForkedExecution&version=3.0.4
#tool nuget:?package=Jobbr.Runtime.ForkedExecution&version=3.0.4
Jobbr Forked Process Execution 
An alternative execution model that starts new processes and executes jobs in these different processes to increase stability.
Jobbr supports multiple execution models as described [here]. The forked execition model is split on the execution extension on the Jobbr-Server and it's counterpart which needs to be included in a simple ConsoleApplication, often referenced as Runner. Please see the [wiki:concept] or more details.
Server Extension
It's assumed that the Jobbr-Server is already installed. The following sample shows the registration of the forked execution mode.
NuGet
Install the NuGet Jobbr.Execution.Forked
to the project where you host your Jobbr-Server. The extension contains everything that is needed to offload jobs to a forked process.
Install-Package Jobbr.Execution.Forked
Registration
using Jobbr.Execution.Forked;
// ....
// Create a new builder which helps to setup your JobbrServer
var builder = new JobbrBuilder();
jobbrBuilder.AddForkedExecution(config =>
{
// Define the executable which runs the jobs.
config.JobRunnerExecutable = "Runner/Demo.JobRunner.exe";
}
);
// Create a new instance of the JobbrServer
var server = builder.Create();
// Start
server.Start();
Configuration
There are additional configuration options beside the required one above.
Name | Description | Default |
---|---|---|
JobRunnerExecutable |
Path to the executable that hosts a Jobbr Runtime and executes your jobs | Required |
JobRunDirectory |
Specifies the folder in which the processes should start (subfolder will be created for each run based on the id) | Required |
BackendAddress |
Defines the URI Prefix to which the forked process should connect to. <br>Note: Should be set manually for production scenarios. to avoid firewall issues. | Auto |
MaxConcurrentProcesses |
Maximum cuncurrent executables that should be forked at a time. Usually correlates with number of Cores | 4 |
IsRuntimeWaitingForDebugger |
If set to true, the executable will wait up to 10s before start (or a dabugger is detected), so that a debugger can be attached to the forked process | false |
AddJobRunnerArguments |
Callback to pass additional parameters to the executable | null |
Note: A more detailed explanation can be found the the [wiki:configuration]
Runner Installation
Creating a runner and setting up all the required dependencies for the runner is your job, a short reminder: The forked execution model bases on an additional executable that executes your job. This additional executable is not part of this package and is under your control. You'll need to reference the related Job-Types in this application. The only additional thing you need to do, is to include the NuGet Package Jobbr.Runtime.ForkedExecution
in you application and start it.
Install-Package Jobbr.Runtime.ForkedExecution
In your Main()
method, make sure you instantiate a new JobbrRuntime and pass all command line arguments to the Start()
-Method.
using Demo.MyJobs;
using Jobbr.Runtime.Logging;
using Jobbr.Runtime.ForkedExecution;
// ...
public static void Main(string[] args)
{
// Redirect Log-Output to Trace, remove this if you install any other Log-Framework
LogProvider.SetCurrentLogProvider(new TraceLogProvider());
// Create the runtime
var runtime = new ForkedRuntime();
// Pass the arguments of the forked execution to the runtime
runtime.Run(args);
}
Configuration
If you want to configure the runtime, please pass an instance of a RuntimeConfiguration
to the constructor. The runtime supports the following configuration properties.
JobType Search Hint
Since the Job is registered by its CLR-Name, the runtime needs to find the related type before instantiating it. The type is queried with the following strategies
- Treat the name as full quelified and try to activate
- Enummerate all types from the
JobTypeSearchAssembly
if provided and match against the Job name - Enummerate all currently loaded assemblies and try to find the job there
- Load all referenced (and not yet loaded assemblies) and query again for the job
Example
// Define the assembly which contains the job
var jobAssemblyToQueryJobs = typeof(ProgressJob).Assembly;
var config = new RuntimeConfiguration { JobTypeSearchAssembly = jobAssemblyToQueryJobs };
var runtime = new ForkedRuntime(config);
Custom Dependency resolver
The default dependency resolver activates the type by using the default constructor. If your job as additional dependencies, you might need to register a dependency resolver that implements the IServiceProvider
-Interface.
Example
// Create a wrapper that implements the IServiceProvider interface and delegates the calls to the used DI
var serviceProvider = new MyDiContainerServiceProviderWrapper(new DIContainer());
var config = new RuntimeConfiguration { ServiceProvider = serviceProvider };
Access to the RuntimeContext
The runtime context contains properties for the current userId and DisplayName that has triggered the jobrun. If you need access to this information, you need to implement the IServiceProviderConfigurator
interface on your DiWrapper so that the runtime is able to register an instance of the RuntimeContext on your DI, which then can be injected to your job afterwards
License
This software is licenced under GPLv3. See LICENSE and the related licences of 3rd party libraries below.
Acknowledgements
Jobbr Server is based on following great open source projects:
Credits
This extension was built by the following awesome developers:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CommandLineParser (>= 2.9.1)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.4)
- System.Text.Json (>= 6.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.