mirror of
https://github.com/bitwarden/server.git
synced 2025-04-17 11:08:16 -05:00
cron logging
This commit is contained in:
parent
fd35ac45b2
commit
4a25da5043
@ -17,6 +17,8 @@ namespace Bit.Jobs
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var parameters = ParseParameters(args);
|
var parameters = ParseParameters(args);
|
||||||
|
try
|
||||||
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseContentRoot(parameters.ContainsKey("d") ? parameters["d"] : Directory.GetCurrentDirectory())
|
.UseContentRoot(parameters.ContainsKey("d") ? parameters["d"] : Directory.GetCurrentDirectory())
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
@ -25,6 +27,15 @@ namespace Bit.Jobs
|
|||||||
|
|
||||||
_logger = host.Services.GetRequiredService<ILogger<Program>>();
|
_logger = host.Services.GetRequiredService<ILogger<Program>>();
|
||||||
_licensingService = host.Services.GetRequiredService<ILicensingService>();
|
_licensingService = host.Services.GetRequiredService<ILicensingService>();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
if(_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogCritical(1, e, "Error while bootstrapping.");
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
MainAsync(parameters).Wait();
|
MainAsync(parameters).Wait();
|
||||||
}
|
}
|
||||||
@ -36,6 +47,10 @@ namespace Bit.Jobs
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Starting job '{0}'.", parameters["j"]);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
switch(parameters["j"])
|
switch(parameters["j"])
|
||||||
{
|
{
|
||||||
case "validate-licenses":
|
case "validate-licenses":
|
||||||
@ -44,13 +59,19 @@ namespace Bit.Jobs
|
|||||||
case "refresh-licenses":
|
case "refresh-licenses":
|
||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
case "hello":
|
case "alive":
|
||||||
_logger.LogInformation("Hello World!");
|
_logger.LogInformation(DateTime.UtcNow.ToString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(2, e, "Error performing job.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static IDictionary<string, string> ParseParameters(string[] args)
|
private static IDictionary<string, string> ParseParameters(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
* * * * * root dotnet /jobs/Jobs.dll -d /jobs -j hello >> /var/log/cron.log 2>&1
|
0 * * * * root dotnet /jobs/Jobs.dll -d /jobs -j alive >> /var/log/cron.log 2>&1
|
||||||
|
0 */6 * * * root dotnet /jobs/Jobs.dll -d /jobs -j validate-licenses >> /var/log/cron.log 2>&1
|
||||||
# An empty line is required at the end of this file for a valid cron file.
|
# An empty line is required at the end of this file for a valid cron file.
|
Loading…
x
Reference in New Issue
Block a user