Skip to content

Commit 0731547

Browse files
authored
Merge pull request #8 from drdk/feature-link-to-logfile
added logpath to status page
2 parents 307908c + 2a277ec commit 0731547

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

ffmpeg-farm-client/Worker/Node.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ private void WriteOutputToLogfile()
294294
if (string.IsNullOrWhiteSpace(_logfilesPath) || !Directory.Exists(_logfilesPath))
295295
return;
296296

297-
string logPath = Path.Combine(_logfilesPath, $@"task_{_currentTask.Id}_output.txt");
297+
var path = Path.Combine(_logfilesPath, _currentTask.Started.Value.ToString("yyyy"), _currentTask.Started.Value.ToString("MM"), _currentTask.Started.Value.ToString("dd"));
298+
299+
Directory.CreateDirectory(path);
300+
301+
string logPath = Path.Combine(path, $@"task_{_currentTask.Id}_output.txt");
298302
using (Stream file = File.Create(logPath))
299303
{
300304
using (var logWriter = new StreamWriter(file))

ffmpeg-farm-server/API.WindowsService/App.Release.config

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
<!-- For more information on using transformations
33
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
44
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
5+
<appSettings>
6+
<add key="FFmpegLogPath" value="\\onddata.net.dr.dk\cache$\MediaCache\ffmpeg-farm\logfiles\"
7+
xdt:Locator="Match(key)" xdt:Transform="SetAttributes" />
8+
</appSettings>
59
</configuration>

ffmpeg-farm-server/API.WindowsService/App.config

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<add key="TimeoutSeconds" value="30" />
66
<add key="WorkerNonResponsiveAlertMinutes" value="10" />
77
<add key="TranscodeToLocalDisk" value="true"/>
8+
<add key="FFmpegLogPath" value="\\ondnas01.net.dr.dk\MediaCache\ffmpeg-farm\logfiles\"/>
89
</appSettings>
910
<connectionStrings>
1011
<add name="mssql" connectionString="Data Source=.;Initial Catalog=ffmpegfarm;Integrated Security=true;MultipleActiveResultSets=True" />

ffmpeg-farm-server/API.WindowsService/Controllers/StatusController.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Configuration;
34
using System.Linq;
45
using System.Net;
56
using System.Net.Http;
@@ -19,6 +20,7 @@ public class StatusController : ApiController
1920
{
2021
private readonly IJobRepository _repository;
2122
private readonly IHelper _helper;
23+
private static readonly string _logPath = ConfigurationManager.AppSettings["FFmpegLogPath"];
2224

2325
public StatusController(IJobRepository repository, IHelper helper)
2426
{
@@ -103,8 +105,9 @@ private static FfmpegJobModel MapDtoToModel(FFmpegJobDto dto)
103105
HeartbeatMachine = j.HeartbeatMachineName,
104106
State = j.State,
105107
Progress = Math.Round(Convert.ToDecimal(j.Progress / j.DestinationDurationSeconds * 100), 2, MidpointRounding.ToEven),
106-
DestinationFilename = j.DestinationFilename
107-
}),
108+
DestinationFilename = j.DestinationFilename,
109+
LogPath = j.Started != null ? $@"{_logPath}{j.Started.Value.Date:yyyy\\MM\\dd}\task_{j.Id}_output.txt" : string.Empty
110+
}),
108111
};
109112
}
110113
}

ffmpeg-farm-server/Contract/Models/FfmpegTaskModel.cs

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ public class FfmpegTaskModel
1414

1515
public string DestinationFilename { get; set; }
1616
public DateTimeOffset? Started { get; set; }
17+
public string LogPath { get; set; }
1718
}
1819
}

0 commit comments

Comments
 (0)