1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 13:38:13 -05:00
This commit is contained in:
Kyle Spearrin 2018-03-27 22:16:55 -04:00
parent 17b7905a41
commit ecb490e8a8
7 changed files with 46 additions and 39 deletions

View File

@ -12,6 +12,7 @@ fi
chown -R bitwarden:bitwarden /app chown -R bitwarden:bitwarden /app
mkdir -p /etc/bitwarden/core mkdir -p /etc/bitwarden/core
mkdir -p /etc/bitwarden/logs
chown -R bitwarden:bitwarden /etc/bitwarden chown -R bitwarden:bitwarden /etc/bitwarden
gosu bitwarden:bitwarden dotnet /app/Admin.dll gosu bitwarden:bitwarden dotnet /app/Admin.dll

View File

@ -15,6 +15,7 @@ chown bitwarden:bitwarden /var/log/cron.log
chown -R bitwarden:bitwarden /app chown -R bitwarden:bitwarden /app
chown -R bitwarden:bitwarden /jobs chown -R bitwarden:bitwarden /jobs
mkdir -p /etc/bitwarden/core mkdir -p /etc/bitwarden/core
mkdir -p /etc/bitwarden/logs
chown -R bitwarden:bitwarden /etc/bitwarden chown -R bitwarden:bitwarden /etc/bitwarden
env >> /etc/environment env >> /etc/environment

View File

@ -17,44 +17,45 @@ namespace Bit.Core.Utilities
GlobalSettings globalSettings, GlobalSettings globalSettings,
Func<LogEvent, bool> filter = null) Func<LogEvent, bool> filter = null)
{ {
if(!env.IsDevelopment()) if(env.IsDevelopment())
{ {
if(filter == null) return factory;
{
filter = (e) => true;
}
var config = new LoggerConfiguration()
.Enrich.FromLogContext()
.Filter.ByIncludingOnly(filter);
if(CoreHelpers.SettingHasValue(globalSettings?.DocumentDb.Uri) &&
CoreHelpers.SettingHasValue(globalSettings?.DocumentDb.Key))
{
config.WriteTo.AzureDocumentDB(new Uri(globalSettings.DocumentDb.Uri),
globalSettings.DocumentDb.Key, timeToLive: TimeSpan.FromDays(7));
}
else if(CoreHelpers.SettingHasValue(globalSettings?.Sentry.Dsn))
{
config.WriteTo.Sentry(globalSettings.Sentry.Dsn)
.Enrich.FromLogContext()
.Enrich.WithProperty("Project", globalSettings.ProjectName)
.Destructure.With<HttpContextDestructingPolicy>()
.Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true);
appBuilder.AddSentryContext();
}
else if(CoreHelpers.SettingHasValue(globalSettings.LogDirectory))
{
config.WriteTo.RollingFile(
$"{globalSettings.LogDirectory}/{globalSettings.ProjectName}/{{Date}}.txt");
}
var serilog = config.CreateLogger();
factory.AddSerilog(serilog);
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
} }
if(filter == null)
{
filter = (e) => true;
}
var config = new LoggerConfiguration()
.Enrich.FromLogContext()
.Filter.ByIncludingOnly(filter);
if(CoreHelpers.SettingHasValue(globalSettings?.DocumentDb.Uri) &&
CoreHelpers.SettingHasValue(globalSettings?.DocumentDb.Key))
{
config.WriteTo.AzureDocumentDB(new Uri(globalSettings.DocumentDb.Uri),
globalSettings.DocumentDb.Key, timeToLive: TimeSpan.FromDays(7));
}
else if(CoreHelpers.SettingHasValue(globalSettings?.Sentry.Dsn))
{
config.WriteTo.Sentry(globalSettings.Sentry.Dsn)
.Enrich.FromLogContext()
.Enrich.WithProperty("Project", globalSettings.ProjectName)
.Destructure.With<HttpContextDestructingPolicy>()
.Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true);
appBuilder.AddSentryContext();
}
else if(CoreHelpers.SettingHasValue(globalSettings.LogDirectory))
{
config.WriteTo.RollingFile($"{globalSettings.LogDirectory}/{globalSettings.ProjectName}/{{Date}}.txt");
}
var serilog = config.CreateLogger();
factory.AddSerilog(serilog);
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
return factory; return factory;
} }
} }

View File

@ -1,6 +1,5 @@
using System; using System;
using Bit.Icons.Services; using Bit.Icons.Services;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;

View File

@ -12,6 +12,7 @@ fi
mkdir -p /etc/bitwarden/identity mkdir -p /etc/bitwarden/identity
mkdir -p /etc/bitwarden/core mkdir -p /etc/bitwarden/core
mkdir -p /etc/bitwarden/logs
chown -R bitwarden:bitwarden /etc/bitwarden chown -R bitwarden:bitwarden /etc/bitwarden
cp /etc/bitwarden/identity/identity.pfx /app/identity.pfx cp /etc/bitwarden/identity/identity.pfx /app/identity.pfx

View File

@ -101,7 +101,8 @@ services:
else else
{ {
sw.Write(@" sw.Write(@"
- ../mssql/data:/var/opt/mssql/data"); - ../mssql/data:/var/opt/mssql/data
- ../logs/mssql:/var/opt/mssql/log");
} }
sw.Write($@" sw.Write($@"
@ -135,6 +136,7 @@ services:
restart: always restart: always
volumes: volumes:
- ../core:/etc/bitwarden/core - ../core:/etc/bitwarden/core
- ../logs/api:/etc/bitwarden/logs
env_file: env_file:
- global.env - global.env
- ../env/uid.env - ../env/uid.env
@ -147,6 +149,7 @@ services:
volumes: volumes:
- ../identity:/etc/bitwarden/identity - ../identity:/etc/bitwarden/identity
- ../core:/etc/bitwarden/core - ../core:/etc/bitwarden/core
- ../logs/identity:/etc/bitwarden/logs
env_file: env_file:
- global.env - global.env
- ../env/uid.env - ../env/uid.env
@ -158,6 +161,7 @@ services:
restart: always restart: always
volumes: volumes:
- ../core:/etc/bitwarden/core - ../core:/etc/bitwarden/core
- ../logs/admin:/etc/bitwarden/logs
env_file: env_file:
- global.env - global.env
- ../env/uid.env - ../env/uid.env
@ -181,7 +185,7 @@ services:
- ../nginx:/etc/bitwarden/nginx - ../nginx:/etc/bitwarden/nginx
- ../letsencrypt:/etc/letsencrypt - ../letsencrypt:/etc/letsencrypt
- ../ssl:/etc/ssl - ../ssl:/etc/ssl
- ../core/logs/nginx:/var/log/nginx - ../logs/nginx:/var/log/nginx
env_file: env_file:
- ../env/uid.env"); - ../env/uid.env");

View File

@ -46,7 +46,7 @@ namespace Bit.Setup
["globalSettings__attachment__baseDirectory"] = $"{OutputDirectory}/core/attachments", ["globalSettings__attachment__baseDirectory"] = $"{OutputDirectory}/core/attachments",
["globalSettings__attachment__baseUrl"] = $"{Url}/attachments", ["globalSettings__attachment__baseUrl"] = $"{Url}/attachments",
["globalSettings__dataProtection__directory"] = $"{OutputDirectory}/core/aspnet-dataprotection", ["globalSettings__dataProtection__directory"] = $"{OutputDirectory}/core/aspnet-dataprotection",
["globalSettings__logDirectory"] = $"{OutputDirectory}/core/logs", ["globalSettings__logDirectory"] = $"{OutputDirectory}/logs",
["globalSettings__licenseDirectory"] = $"{OutputDirectory}/core/licenses", ["globalSettings__licenseDirectory"] = $"{OutputDirectory}/core/licenses",
["globalSettings__duo__aKey"] = $"{Helpers.SecureRandomString(64, alpha: true, numeric: true)}", ["globalSettings__duo__aKey"] = $"{Helpers.SecureRandomString(64, alpha: true, numeric: true)}",
["globalSettings__installation__id"] = InstallationId?.ToString(), ["globalSettings__installation__id"] = InstallationId?.ToString(),