Skip to content

Commit 04f1779

Browse files
committed
Update help text, fleshout docs, add scheduler scripts
1 parent 6996f2d commit 04f1779

File tree

12 files changed

+182
-20
lines changed

12 files changed

+182
-20
lines changed

docs-src/commands.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ namespace MyCommandPlugin
6565
}
6666
```
6767

68+
6869
## Run a Command
6970

7071
Create a class that implements **InEngine.Core.IOptions** in the same assembly as the command class.
@@ -102,7 +103,7 @@ Run your command...
102103
InEngineCli.exe -pMyCommandPlugin my-command
103104
```
104105

105-
## Discover Commands Plugins
106+
## Discover Command Plugins
106107

107108
Run InEngineCli.exe without any arguments to see a list of arguments.
108109

@@ -121,10 +122,10 @@ InEngineCli.exe -pInEngine.Core
121122
```
122123

123124
The **InEngine.Core** library is itself a plugin that contains queue related commands.
124-
This is the help output for the core plugin.
125+
As an example, this is the help output for the core plugin.
125126

126127
```text
127-
InEngine 3.1.0
128+
InEngine 3.x
128129
Copyright © Ethan Hann 2017
129130
130131
queue:publish Publish a command message to a queue.
@@ -148,11 +149,87 @@ InEngineCli.exe -pInEngine.Core queue:clear -h
148149
The **InEngine.Core** plugin's command to clear the InEngine.NET's queues produces this help message.
149150

150151
```text
151-
InEngine 3.1.0
152+
InEngine 3.x
152153
Copyright © Ethan Hann 2017
153154
154155
--processing-queue Clear the processing queue.
155156
156157
--secondary Clear the secondary queue.
157158
```
158159

160+
161+
## Logging
162+
163+
The **InEngine.Core.AbstractCommand** class provides a Logger property. It implements the **NLog.ILogger** interface.
164+
165+
```csharp
166+
using System;
167+
using InEngine.Core;
168+
169+
namespace MyCommandPlugin
170+
{
171+
public class MyCommand : ICommand
172+
{
173+
public override CommandResult Run()
174+
{
175+
Logger.Trace("Sample trace message");
176+
Logger.Debug("Sample debug message");
177+
Logger.Info("Sample informational message");
178+
Logger.Warn("Sample warning message");
179+
Logger.Error("Sample error message");
180+
Logger.Fatal("Sample fatal error message");
181+
return new CommandResult(true);
182+
}
183+
}
184+
}
185+
```
186+
187+
Setup an [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file, something like this...
188+
189+
```xml
190+
<?xml version="1.0" encoding="utf-8" ?>
191+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
192+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
193+
194+
<targets>
195+
<target name="logfile" xsi:type="File" fileName="file.txt" />
196+
<target name="console" xsi:type="Console" />
197+
</targets>
198+
199+
<rules>
200+
<logger name="*" minlevel="Trace" writeTo="logfile" />
201+
<logger name="*" minlevel="Info" writeTo="console" />
202+
</rules>
203+
</nlog>
204+
```
205+
206+
## Progress Bar
207+
208+
The **InEngine.Core.AbstractCommand** class provides a ProgressBar property. This is how it is used.
209+
210+
```csharp
211+
using InEngine.Core;
212+
213+
namespace MyCommandPlugin
214+
{
215+
public class MyCommand : AbstractCommand
216+
{
217+
public override CommandResult Run()
218+
{
219+
// Define the ticks (aka steps) for the command...
220+
var maxTicks = 100000;
221+
SetProgressBarMaxTicks(maxTicks);
222+
223+
// Do some work...
224+
for (var i = 0; i <= maxTicks;i++)
225+
{
226+
// Update the command's progress
227+
UpdateProgress(i);
228+
}
229+
230+
return new CommandResult(true);
231+
}
232+
}
233+
}
234+
```
235+

docs-src/css/style.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
.navbar-default {
2-
background: #2f2f2f;
2+
background: #0a69fa;
33
}
44

55
.navbar-default .navbar-nav > .active > a,
66
.navbar-default .navbar-nav > .active > a:hover,
77
.navbar-default .navbar-nav > .active > a:focus {
8-
background-color: #0f0f0f;
8+
background-color: #0a69fa;
99
}
1010

1111
.navbar-default .navbar-nav > li > a:hover,
1212
.navbar-default .navbar-nav > li > a:focus {
13-
background-color: #0f0f0f;
13+
background-color: #0a69fa;
1414
}
1515

1616
a,

docs-src/scheduling.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Scheduling
2+
3+
[Commands](commands) can be scheduled to run by leveraging the InEngineScheduler.exe program, available as a download from a recent [release](https://github.com/InEngine-NET/InEngine.NET/releases).
4+
5+
## Manually Running the Scheduler
6+
7+
Running the scheduler from the CommandLine is useful for debugging or local development. Simply run *InEngineScheduler.exe* from the command line.
8+
9+
```bash
10+
InEngineScheduler.exe
11+
```
12+
13+
It can also be run on Mac/Linux with Mono.
14+
15+
```bash
16+
mono InEngineScheduler.exe
17+
```
18+
19+
## Running as a Windows Service
20+
21+
22+
### Installing as a Windows Service
23+
Run the Install.ps1 PowerShell script in the scheduler directory to install the scheduler in place. The script needs to be run as an administrator. The script will register the service at the location where the script is run.
24+
25+
```bash
26+
ps Install.ps1
27+
```
28+
29+
### Uninstalling the Windows Service
30+
31+
Simply run the **Uninstall.ps1** script with elevated permissions to unregister the service.
32+
33+
```bash
34+
ps Uninstall.ps1
35+
```
36+
37+
## Running with Supervisor (on Linux)
38+
39+
Supervisor is a process control system for Linux. It has extensive [documentation](http://supervisord.org/index.html), but the following should be enough to get started.
40+
41+
### Installing Supervisor
42+
43+
This command installs Supervisor on Ubuntu:
44+
45+
```
46+
sudo apt-get install supervisor
47+
```
48+
49+
### Configuring Supervisor
50+
51+
Supervisor configuration files are stored in the **/etc/supervisor/conf.d** directory. Multiple files can be created in this directory to specify different programs, or multiple instances of the same program, for Supervisor to monitor. Copy this sample config into a file called **/etc/supervisor/conf.d/inengine-scheduler.conf**.
52+
53+
```ini
54+
[program:inengine-scheudler]
55+
process_name=%(program_name)s_%(process_num)02d
56+
directory=/path/to/scheduler
57+
command=mono InEngineScheduler.exe
58+
autostart=true
59+
autorestart=true
60+
user=InEngine
61+
numprocs=1
62+
redirect_stderr=true
63+
stdout_logfile=./scheduler.log
64+
```
65+
66+
### Starting Supervisor
67+
68+
Whenever a configuration change happens to files in the Supervisor config files, Supervisor needs to be instructed to reload its configuration.
69+
70+
```bash
71+
sudo supervisorctl reread
72+
sudo supervisorctl update
73+
```
74+
75+
Now, simply start the InEngine Scheduler.
76+
77+
```bash
78+
sudo supervisorctl start inengine-scheduler:*
79+
```
80+
81+

mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ copyright: © 2017 - Ethan Hann
77

88
pages:
99
- Getting Started: 'index.md'
10-
- commands.md
10+
- Documentation:
11+
- commands.md
12+
- scheduling.md
1113

1214
extra_css:
1315
- css/style.css
14-

src/InEngine.Core/AbstractCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace InEngine.Core
77
abstract public class AbstractCommand : ICommand, IJob
88
{
99
public IJobExecutionContext JobExecutionContext { get; set; }
10-
public Logger Logger { get; internal set; }
10+
public ILogger Logger { get; internal set; }
1111
public ProgressBar ProgressBar { get; internal set; }
1212
string _name;
1313
public string Name

src/InEngine.Core/Queue/Commands/Consume.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ namespace InEngine.Core.Queue.Commands
55
{
66
public class Consume : AbstractCommand
77
{
8-
[Option("all", DefaultValue = false)]
8+
[Option("all", HelpText = "Consume all the messages in the primary or secondary queue.")]
99
public bool ShouldConsumeAll { get; set; }
1010

11-
[Option("secondary", DefaultValue = false, HelpText = "Consume from a secondary queue.")]
11+
[Option("secondary", DefaultValue = false, HelpText = "Consume from the secondary queue.")]
1212
public bool UseSecondaryQueue { get; set; }
1313

1414
public override CommandResult Run()

src/InEngine.Core/Queue/Commands/GetLength.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ namespace InEngine.Core.Queue.Commands
55
{
66
public class GetLength : AbstractCommand
77
{
8-
[Option("processing-queue", HelpText = "Display the number of command actively running.")]
9-
public bool CheckProcessingQueue { get; set; }
10-
118
public override CommandResult Run()
129
{
1310
var broker = Broker.Make();

src/InEngine.Core/Queue/Commands/Null.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using System;
2-
namespace InEngine.Core.Queue.Commands
1+
namespace InEngine.Core.Queue.Commands
32
{
3+
/// <summary>
4+
/// Dummy command for testing and sample code.
5+
/// </summary>
46
public class Null : AbstractCommand
57
{
68
public override CommandResult Run()

src/InEngine.Core/Queue/Commands/Publish.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.IO;
2-
using System.Linq;
3-
using System.Reflection;
1+
using System.Linq;
42
using CommandLine;
53

64
namespace InEngine.Core.Queue.Commands

src/InEngineScheduler/InEngineScheduler.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
<None Include="appsettings.json">
6464
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6565
</None>
66+
<None Include="Install.ps1">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
69+
<None Include="Uninstall.ps1" />
6670
</ItemGroup>
6771
<ItemGroup>
6872
<ProjectReference Include="..\InEngine.Core\InEngine.Core.csproj">

0 commit comments

Comments
 (0)