Skip to content

Commit c24630e

Browse files
committed
Switch to Common.Logging
1 parent f44ae6d commit c24630e

24 files changed

+161
-241
lines changed

docs-src/commands.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,3 @@ Copyright © 2017 Ethan Hann
235235
queue.
236236
```
237237

238-
## Logging
239-
240-
Any exceptions thrown by a command will be logged provided NLog is configured to record errors.
241-
The [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file needs to be setup with something like this:
242-
243-
```xml
244-
<?xml version="1.0" encoding="utf-8" ?>
245-
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
246-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
247-
248-
<targets>
249-
<target name="logfile" xsi:type="File" fileName="inengine.log" />
250-
</targets>
251-
252-
<rules>
253-
<logger name="*" minlevel="Error" writeTo="logfile" />
254-
</rules>
255-
</nlog>
256-
```

docs-src/configuration.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Configuration
22

3+
## InEngine Settings
34
Configuration is accomplished by modifying the appsettings.json file that comes with the InEngine.NET binary distribution.
45
The **-c, --configuration** argument can also be used to specify an alternate configuration file.
56

@@ -65,3 +66,30 @@ The **-c, --configuration** argument can also be used to specify an alternate co
6566
| RedisPort | integer | Redis's port. |
6667
| RedisDb | integer | The Redis database - 0-15 |
6768
| RedisPassword | string | The Redis auth password |
69+
70+
71+
## Logging Settings
72+
73+
Any exceptions thrown by a command will be logged, provided NLog is configured to log exceptions.
74+
The [NLog configuration](https://github.com/NLog/NLog/wiki/Tutorial#configuration) file needs to be setup with something like this:
75+
76+
```xml
77+
<?xml version="1.0" encoding="utf-8" ?>
78+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
79+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
80+
81+
<targets>
82+
<target name="logfile" xsi:type="File" fileName="inengine.log" />
83+
</targets>
84+
85+
<rules>
86+
<logger name="*" minlevel="Error" writeTo="logfile" />
87+
</rules>
88+
</nlog>
89+
```
90+
91+
InEngine.Core does not depend explicitly on NLog, but rather [Common.Logging](http://net-commons.github.io/common-logging/).
92+
This means that any logging framework that Common.Logging supports can be used.
93+
Configuring Common.Logging to use a different logging framework is out of the scope of this documentation.
94+
95+

docs-src/scheduling.md

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ namespace MyCommandPlugin
235235

236236
## Running the Scheduler
237237

238-
### Manually from the CLI
238+
There are a [variety of ways](server) to run the scheduler. The simplest way is from the command line.
239239

240240
Running the scheduler from the CommandLine is useful for debugging or local development:
241241

@@ -248,78 +248,3 @@ It can also be run on Mac and Linux with Mono via a shell wrapper script:
248248
```bash
249249
./inengine -s
250250
```
251-
252-
### On Windows as a Service
253-
254-
Run the **Install.ps1** PowerShell script in the scheduler directory to install the scheduler in place.
255-
The script needs to be run as an administrator.
256-
The script will register the service at the location where the script is run.
257-
258-
```bash
259-
ps Install.ps1
260-
```
261-
262-
Simply run the **Uninstall.ps1** script with elevated permissions to remove the service.
263-
264-
```bash
265-
ps Uninstall.ps1
266-
```
267-
268-
### On Linux with Supervisor
269-
270-
Supervisor is a process control system for Linux.
271-
It has extensive [documentation](http://supervisord.org/index.html), but the following should be enough to get started.
272-
273-
#### Installing Supervisor
274-
275-
This command installs Supervisor on Ubuntu:
276-
277-
```bash
278-
sudo apt-get install supervisor
279-
```
280-
281-
#### Configuring Supervisor
282-
283-
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**.
284-
285-
```ini
286-
[program:inengine]
287-
process_name=%(program_name)s_%(process_num)02d
288-
directory=/path/to/inengine
289-
command=mono inengine.exe -s
290-
autostart=true
291-
autorestart=true
292-
user=InEngine
293-
numprocs=1
294-
redirect_stderr=true
295-
stdout_logfile=./scheduler.log
296-
```
297-
298-
#### Starting Supervisor
299-
300-
Whenever a configuration change happens to files in the Supervisor config files, Supervisor needs to be instructed to reload its configuration.
301-
302-
```bash
303-
sudo supervisorctl reread
304-
sudo supervisorctl update
305-
```
306-
307-
Now, simply start the scheduler workers with the **supervisorctl** program:
308-
309-
```bash
310-
sudo supervisorctl start inengine:*
311-
```
312-
313-
### In a Container with Docker
314-
315-
Install [Docker](https://www.docker.com/what-docker) first, then pull the **ethanhann/inengine** image:
316-
317-
```bash
318-
docker pull ethanhann/inengine:latest
319-
```
320-
321-
Now run the scheduler:
322-
323-
```bash
324-
docker run --rm inengine -s
325-
```

docs-src/server.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# The InEngine Server
2+
3+
When run as a service, InEngine runs scheduled commands in the background and actively listens for commands to be queued.
4+
5+
## Running the Server
6+
7+
### In the Foreground
8+
9+
Running the server from the CommandLine is useful for debugging or local development:
10+
11+
```bash
12+
inengine.exe -s
13+
```
14+
15+
It can also be run on Mac and Linux with Mono via a shell wrapper script:
16+
17+
```bash
18+
./inengine -s
19+
```
20+
21+
### On Windows as a Service
22+
23+
Run the **Install.ps1** PowerShell script in the InEngine directory to install the InEngine as a service.
24+
The script needs to be run as an administrator.
25+
The script will register the service at the location where the script is run - i.e. put the files where you want them installed before running the installation script.
26+
27+
```bash
28+
ps Install.ps1
29+
```
30+
31+
Simply run the **Uninstall.ps1** script with elevated permissions to remove the service.
32+
33+
```bash
34+
ps Uninstall.ps1
35+
```
36+
37+
### On Linux with Supervisor
38+
39+
Supervisor is a process control system for Linux.
40+
It has extensive [documentation](http://supervisord.org/index.html), but the following should be enough to get started.
41+
42+
#### Installing Supervisor
43+
44+
This command installs Supervisor on Ubuntu:
45+
46+
```bash
47+
sudo apt-get install supervisor
48+
```
49+
50+
#### Configuring Supervisor
51+
52+
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**.
53+
54+
```ini
55+
[program:inengine]
56+
process_name=%(program_name)s_%(process_num)02d
57+
directory=/path/to/inengine
58+
command=mono inengine.exe -s
59+
autostart=true
60+
autorestart=true
61+
user=InEngine
62+
numprocs=1
63+
redirect_stderr=true
64+
stdout_logfile=./scheduler.log
65+
```
66+
67+
#### Starting Supervisor
68+
69+
Whenever a configuration change happens to files in the Supervisor config files, Supervisor needs to be instructed to reload its configuration.
70+
71+
```bash
72+
sudo supervisorctl reread
73+
sudo supervisorctl update
74+
```
75+
76+
Now, simply start the server workers with the **supervisorctl** program:
77+
78+
```bash
79+
sudo supervisorctl start inengine:*
80+
```
81+
82+
### In a Container with Docker
83+
84+
Install [Docker](https://www.docker.com/what-docker) first, then pull the **ethanhann/inengine** image:
85+
86+
```bash
87+
docker pull ethanhann/inengine:latest
88+
```
89+
90+
Now run the InEngine in server mode:
91+
92+
```bash
93+
docker run --rm inengine -s

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pages:
1616
- scheduling.md
1717
- queuing.md
1818
- configuration.md
19+
- server.md
1920

2021
extra_css:
2122
- css/style.css

src/InEngine.Core/InEngine.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<Folder Include="Queuing\Message\" />
3939
<Folder Include="Scheduling\LifeCycle\" />
4040
<Folder Include="LifeCycle\" />
41-
<Folder Include="Logging\" />
4241
</ItemGroup>
4342
<ItemGroup>
4443
<Reference Include="System.ComponentModel.DataAnnotations" />

src/InEngine.Core/Logging/ILog.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/InEngine.Core/Logging/Log.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/InEngine.Core/Queuing/Clients/FileClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
using System.IO;
44
using System.Linq;
55
using System.Threading;
6+
using Common.Logging;
67
using InEngine.Core.Exceptions;
7-
using InEngine.Core.Logging;
88
using InEngine.Core.Queuing.Message;
99

1010
namespace InEngine.Core.Queuing.Clients
1111
{
1212
public class FileClient : IQueueClient
1313
{
14-
public ILog Log { get; set; } = new Log();
14+
public ILog Log { get; set; } = LogManager.GetLogger<FileClient>();
1515
public int Id { get; set; } = 0;
1616
public string QueueBaseName { get; set; }
1717
public string QueueName { get; set; }

src/InEngine.Core/Queuing/Clients/RedisClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
using System.Linq;
44
using System.Threading;
55
using System.Threading.Tasks;
6+
using Common.Logging;
67
using InEngine.Core.Exceptions;
7-
using InEngine.Core.Logging;
88
using InEngine.Core.Queuing.Message;
99
using StackExchange.Redis;
1010

1111
namespace InEngine.Core.Queuing.Clients
1212
{
1313
public class RedisClient : IQueueClient
1414
{
15-
public ILog Log { get; set; } = new Log();
15+
public ILog Log { get; set; } = LogManager.GetLogger<RedisClient>();
1616
public int Id { get; set; } = 0;
1717
public string QueueBaseName { get; set; } = "InEngineQueue";
1818
public string QueueName { get; set; } = "Primary";

0 commit comments

Comments
 (0)