Last change
on this file since 16998 was
16998,
checked in by dpiringe, 5 years ago
|
#2924:
- in project HeuristicLab.CommandLineInterface changed output for options -> hidden options are not shown in the help box anymore
- in project HeuristicLab.DynamicAssemblyTestApp:
- added ApplicationAttributes
- added full cancel/pause/resume support for class AppTest to test the same behaviour between main and child process
- in project HeuristicLab:
- changed auto generated Dockerfile -> only copies necessary projects -> speeds up the build process
- in file HeuristicLab-3.3.csproj:
- changed DockerDefaultTargetOS to Linux
- removed reference HeuristicLab.DefinitionLanguage
- added icon and manifest
- deleted folder Properties with file launchSettings.json
- changed the direct access to ApplicationTypes for OptimizeCommand and InspectCommand to new method IApplicationManager.GetInstances<T>(params object[] args)
- added build script for docker image dockerImageBuild.ps1
|
File size:
1.9 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.IO;
|
---|
3 | using HeuristicLab.CommandLineInterface;
|
---|
4 | using HeuristicLab.PluginInfrastructure;
|
---|
5 |
|
---|
6 | namespace HeuristicLab {
|
---|
7 |
|
---|
8 | public enum IsolationType {
|
---|
9 | Docker,
|
---|
10 | Native
|
---|
11 | }
|
---|
12 |
|
---|
13 | [CommandLineInterface.Application(
|
---|
14 | "HL", "1.0.0.0",
|
---|
15 | SubCommands = new Type[] {
|
---|
16 | typeof(OptimizeCommand),
|
---|
17 | typeof(BuildCommand),
|
---|
18 | typeof(InspectCommand)
|
---|
19 | }
|
---|
20 | )]
|
---|
21 | class ApplicationCommand : ICommand {
|
---|
22 |
|
---|
23 | [Option(Description = "Sets the path for the binaries.")]
|
---|
24 | public string BasePath { get; set; }
|
---|
25 |
|
---|
26 | [Option(Shortcut = "i", Description = "Sets the isolation type. Possible types are: NATIVE or DOCKER.")]
|
---|
27 | public IsolationType Isolation { get; set; }
|
---|
28 |
|
---|
29 | [Option]
|
---|
30 | private bool StartAsRunnerHost { get; set; }
|
---|
31 |
|
---|
32 | public void Execute() {
|
---|
33 | if (StartAsRunnerHost) {
|
---|
34 | StartupRunnerHost();
|
---|
35 | } else {
|
---|
36 | SetupIsolation();
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | private void StartupRunnerHost() {
|
---|
41 | Stream stdin = Console.OpenStandardInput();
|
---|
42 | IRunner runner = Runner.Deserialize(stdin);
|
---|
43 |
|
---|
44 | if (runner != null)
|
---|
45 | runner.Run();
|
---|
46 | else
|
---|
47 | Console.Error.WriteLine("Cannot deserialize data from stdin to a type of RunnerConfig!");
|
---|
48 | }
|
---|
49 |
|
---|
50 | private void SetupIsolation() {
|
---|
51 | switch (Isolation) {
|
---|
52 | case IsolationType.Native: Settings.Host = new NativeRunnerHost(); break;
|
---|
53 | case IsolationType.Docker: Settings.Host = new DockerRunnerHost(); break;
|
---|
54 | default: throw new ArgumentException("Invalid value for isolation.", "Isolation");
|
---|
55 | }
|
---|
56 |
|
---|
57 | if (BasePath != null && !Directory.Exists(BasePath))
|
---|
58 | throw new DirectoryNotFoundException("Path for binaries is not a directory or does not exists.");
|
---|
59 | else BasePath = Directory.GetCurrentDirectory();
|
---|
60 |
|
---|
61 | IPluginLoader validator = PluginLoaderFactory.Create();
|
---|
62 | Settings.assemblyInfos = validator.Validate(BasePath);
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.