This commit is contained in:
Ryan Nowak 2020-02-29 12:54:22 -08:00
Родитель ab5946c687
Коммит 113a0e5059
55 изменённых файлов: 4923 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,74 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Micronetes.Hosting.Diagnostics
{
public class DiagnosticOptions
{
public (string Key, string Value) LoggingProvider { get; set; }
public (string Key, string Value) DistributedTraceProvider { get; set; }
public (string Key, string Value) MetricsProvider { get; set; }
public static DiagnosticOptions FromConfiguration(IConfiguration configuration)
{
return new DiagnosticOptions
{
LoggingProvider = GetProvider(configuration, "logs"),
DistributedTraceProvider = GetProvider(configuration, "dtrace"),
MetricsProvider = GetProvider(configuration, "metrics")
};
}
private static (string, string) GetProvider(IConfiguration configuration, string providerName)
{
var providerString = configuration[providerName];
if (string.IsNullOrEmpty(providerString))
{
return (null, null);
}
var pair = providerString.Split('=');
if (pair.Length < 2)
{
return (pair[0].Trim(), null);
}
return (pair[0].Trim(), pair[1].Trim());
}
public void DumpDiagnostics(ILogger logger)
{
var (logProviderKey, logProviderValue) = LoggingProvider;
var (dTraceProviderKey, dTraceProviderValue) = DistributedTraceProvider;
switch (logProviderKey?.ToLowerInvariant())
{
case "elastic":
logger.LogInformation("logs: Using ElasticSearch at {URL}", logProviderValue);
break;
case "ai":
logger.LogInformation("logs: Using ApplicationInsights instrumentation key {InstrumentationKey}", logProviderValue);
break;
case "console":
logger.LogInformation("logs: Using console logs");
break;
case "seq":
logger.LogInformation("logs: Using Seq at {URL}", logProviderValue);
break;
default:
break;
}
switch (dTraceProviderKey?.ToLowerInvariant())
{
case "zipkin":
logger.LogInformation("dtrace: Using Zipkin at URL {URL}", dTraceProviderValue);
break;
default:
break;
}
}
}
}

Просмотреть файл

@ -0,0 +1,853 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Micronetes.Hosting.Diagnostics.Logging;
using Micronetes.Hosting.Diagnostics.Metrics;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Parsers;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Exporter.Zipkin;
using OpenTelemetry.Trace;
using OpenTelemetry.Trace.Export;
using Serilog;
namespace Micronetes.Hosting.Diagnostics
{
public class DiagnosticsCollector
{
// This list of event sources needs to be extensible
private static readonly string MicrosoftExtensionsLoggingProviderName = "Microsoft-Extensions-Logging";
private static readonly string SystemRuntimeEventSourceName = "System.Runtime";
private static readonly string MicrosoftAspNetCoreHostingEventSourceName = "Microsoft.AspNetCore.Hosting";
private static readonly string GrpcAspNetCoreServer = "Grpc.AspNetCore.Server";
private static readonly string DiagnosticSourceEventSource = "Microsoft-Diagnostics-DiagnosticSource";
private static readonly string TplEventSource = "System.Threading.Tasks.TplEventSource";
// This is the list of events for distributed tracing
private static readonly string DiagnosticFilterString = "\"" +
"Microsoft.AspNetCore/Microsoft.AspNetCore.Hosting.HttpRequestIn.Start@Activity1Start:-" +
"Request.Scheme" +
";Request.Host" +
";Request.PathBase" +
";Request.QueryString" +
";Request.Path" +
";Request.Method" +
";ActivityStartTime=*Activity.StartTimeUtc.Ticks" +
";ActivityParentId=*Activity.ParentId" +
";ActivityId=*Activity.Id" +
";ActivitySpanId=*Activity.SpanId" +
";ActivityTraceId=*Activity.TraceId" +
";ActivityParentSpanId=*Activity.ParentSpanId" +
";ActivityIdFormat=*Activity.IdFormat" +
"\r\n" +
"Microsoft.AspNetCore/Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop@Activity1Stop:-" +
"Response.StatusCode" +
";ActivityDuration=*Activity.Duration.Ticks" +
";ActivityId=*Activity.Id" +
"\r\n" +
"HttpHandlerDiagnosticListener/System.Net.Http.HttpRequestOut@Event:-" +
"\r\n" +
"HttpHandlerDiagnosticListener/System.Net.Http.HttpRequestOut.Start@Activity2Start:-" +
"Request.RequestUri" +
";Request.Method" +
";Request.RequestUri.Host" +
";Request.RequestUri.Port" +
";ActivityStartTime=*Activity.StartTimeUtc.Ticks" +
";ActivityId=*Activity.Id" +
";ActivitySpanId=*Activity.SpanId" +
";ActivityTraceId=*Activity.TraceId" +
";ActivityParentSpanId=*Activity.ParentSpanId" +
";ActivityIdFormat=*Activity.IdFormat" +
";ActivityId=*Activity.Id" +
"\r\n" +
"HttpHandlerDiagnosticListener/System.Net.Http.HttpRequestOut.Stop@Activity2Stop:-" +
";ActivityDuration=*Activity.Duration.Ticks" +
";ActivityId=*Activity.Id" +
"\r\n" +
"\"";
private readonly Microsoft.Extensions.Logging.ILogger _logger;
private readonly DiagnosticOptions _options;
public DiagnosticsCollector(Microsoft.Extensions.Logging.ILogger logger, DiagnosticOptions options)
{
_logger = logger;
_options = options;
}
public void ProcessEvents(string applicationName,
string serviceName,
int processId,
string replicaName,
IDictionary<string, string> metrics,
CancellationToken cancellationToken)
{
var hasEventPipe = false;
for (int i = 0; i < 10; ++i)
{
if (DiagnosticsClient.GetPublishedProcesses().Contains(processId))
{
hasEventPipe = true;
break;
}
if (cancellationToken.IsCancellationRequested)
{
return;
}
Thread.Sleep(500);
}
if (!hasEventPipe)
{
_logger.LogInformation("Process id {PID}, does not support event pipe", processId);
return;
}
_logger.LogInformation("Listening for event pipe events for {ServiceName} on process id {PID}", replicaName, processId);
// Create the logger factory for this replica
using var loggerFactory = LoggerFactory.Create(builder => ConfigureLogging(serviceName, replicaName, builder));
var processor = new SimpleSpanProcessor(CreateSpanExporter(serviceName, replicaName));
var providers = new List<EventPipeProvider>()
{
// Runtime Metrics
new EventPipeProvider(
SystemRuntimeEventSourceName,
EventLevel.Informational,
(long)ClrTraceEventParser.Keywords.None,
new Dictionary<string, string>() {
{ "EventCounterIntervalSec", "1" }
}
),
new EventPipeProvider(
MicrosoftAspNetCoreHostingEventSourceName,
EventLevel.Informational,
(long)ClrTraceEventParser.Keywords.None,
new Dictionary<string, string>() {
{ "EventCounterIntervalSec", "1" }
}
),
new EventPipeProvider(
GrpcAspNetCoreServer,
EventLevel.Informational,
(long)ClrTraceEventParser.Keywords.None,
new Dictionary<string, string>() {
{ "EventCounterIntervalSec", "1" }
}
),
// Application Metrics
new EventPipeProvider(
applicationName,
EventLevel.Informational,
(long)ClrTraceEventParser.Keywords.None,
new Dictionary<string, string>() {
{ "EventCounterIntervalSec", "1" }
}
),
// Logging
new EventPipeProvider(
MicrosoftExtensionsLoggingProviderName,
EventLevel.LogAlways,
(long)(LoggingEventSource.Keywords.JsonMessage | LoggingEventSource.Keywords.FormattedMessage)
),
// Distributed Tracing
// Activity correlation
new EventPipeProvider(TplEventSource,
keywords: 0x80,
eventLevel: EventLevel.LogAlways),
// Diagnostic source events
new EventPipeProvider(DiagnosticSourceEventSource,
keywords: 0x1 | 0x2,
eventLevel: EventLevel.Verbose,
arguments: new Dictionary<string,string>
{
{ "FilterAndPayloadSpecs", DiagnosticFilterString }
})
};
while (!cancellationToken.IsCancellationRequested)
{
EventPipeSession session = null;
var client = new DiagnosticsClient(processId);
try
{
session = client.StartEventPipeSession(providers);
}
catch (EndOfStreamException)
{
break;
}
catch (Exception ex)
{
if (!cancellationToken.IsCancellationRequested)
{
_logger.LogDebug(0, ex, "Failed to start the event pipe session");
}
// We can't even start the session, wait until the process boots up again to start another metrics thread
break;
}
void StopSession()
{
try
{
session.Stop();
}
catch (EndOfStreamException)
{
// If the app we're monitoring exits abruptly, this may throw in which case we just swallow the exception and exit gracefully.
}
// We may time out if the process ended before we sent StopTracing command. We can just exit in that case.
catch (TimeoutException)
{
}
// On Unix platforms, we may actually get a PNSE since the pipe is gone with the process, and Runtime Client Library
// does not know how to distinguish a situation where there is no pipe to begin with, or where the process has exited
// before dotnet-counters and got rid of a pipe that once existed.
// Since we are catching this in StopMonitor() we know that the pipe once existed (otherwise the exception would've
// been thrown in StartMonitor directly)
catch (PlatformNotSupportedException)
{
}
}
using var _ = cancellationToken.Register(() => StopSession());
try
{
var source = new EventPipeEventSource(session.EventStream);
// Distribued Tracing
HandleDistributedTracingEvents(source, processor);
// Metrics
HandleEventCounters(source, metrics);
// Logging
HandleLoggingEvents(source, loggerFactory, replicaName);
source.Process();
}
catch (DiagnosticsClientException ex)
{
_logger.LogDebug(0, ex, "Failed to start the event pipe session");
}
catch (Exception)
{
// This fails if stop is called or if the process dies
}
finally
{
session?.Dispose();
}
}
_logger.LogInformation("Event pipe collection completed for {ServiceName} on process id {PID}", replicaName, processId);
}
private void HandleLoggingEvents(EventPipeEventSource source, ILoggerFactory loggerFactory, string replicaName)
{
string lastFormattedMessage = "";
var logActivities = new Dictionary<Guid, LogActivityItem>();
var stack = new Stack<Guid>();
source.Dynamic.AddCallbackForProviderEvent(MicrosoftExtensionsLoggingProviderName, "ActivityJsonStart/Start", (traceEvent) =>
{
var factoryId = (int)traceEvent.PayloadByName("FactoryID");
var categoryName = (string)traceEvent.PayloadByName("LoggerName");
var argsJson = (string)traceEvent.PayloadByName("ArgumentsJson");
// TODO: Store this information by logger factory id
var item = new LogActivityItem
{
ActivityID = traceEvent.ActivityID,
ScopedObject = new LogObject(JsonDocument.Parse(argsJson).RootElement),
};
if (stack.TryPeek(out var parentId) && logActivities.TryGetValue(parentId, out var parentItem))
{
item.Parent = parentItem;
}
stack.Push(traceEvent.ActivityID);
logActivities[traceEvent.ActivityID] = item;
});
source.Dynamic.AddCallbackForProviderEvent(MicrosoftExtensionsLoggingProviderName, "ActivityJsonStop/Stop", (traceEvent) =>
{
var factoryId = (int)traceEvent.PayloadByName("FactoryID");
var categoryName = (string)traceEvent.PayloadByName("LoggerName");
stack.Pop();
logActivities.Remove(traceEvent.ActivityID);
});
source.Dynamic.AddCallbackForProviderEvent(MicrosoftExtensionsLoggingProviderName, "MessageJson", (traceEvent) =>
{
// Level, FactoryID, LoggerName, EventID, EventName, ExceptionJson, ArgumentsJson
var logLevel = (LogLevel)traceEvent.PayloadByName("Level");
var factoryId = (int)traceEvent.PayloadByName("FactoryID");
var categoryName = (string)traceEvent.PayloadByName("LoggerName");
var eventId = (int)traceEvent.PayloadByName("EventId");
var eventName = (string)traceEvent.PayloadByName("EventName");
var exceptionJson = (string)traceEvent.PayloadByName("ExceptionJson");
var argsJson = (string)traceEvent.PayloadByName("ArgumentsJson");
// There's a bug that causes some of the columns to get mixed up
if (eventName.StartsWith("{"))
{
argsJson = exceptionJson;
exceptionJson = eventName;
eventName = null;
}
if (string.IsNullOrEmpty(argsJson))
{
return;
}
Exception exception = null;
var logger = loggerFactory.CreateLogger(categoryName);
var scopes = new List<IDisposable>();
if (logActivities.TryGetValue(traceEvent.ActivityID, out var logActivityItem))
{
// REVIEW: Does order matter here? We're combining everything anyways.
while (logActivityItem != null)
{
scopes.Add(logger.BeginScope(logActivityItem.ScopedObject));
logActivityItem = logActivityItem.Parent;
}
}
try
{
if (exceptionJson != "{}")
{
var exceptionMessage = JsonSerializer.Deserialize<JsonElement>(exceptionJson);
exception = new LoggerException(exceptionMessage);
}
var message = JsonSerializer.Deserialize<JsonElement>(argsJson);
if (message.TryGetProperty("{OriginalFormat}", out var formatElement))
{
var formatString = formatElement.GetString();
var formatter = new LogValuesFormatter(formatString);
object[] args = new object[formatter.ValueNames.Count];
for (int i = 0; i < args.Length; i++)
{
args[i] = message.GetProperty(formatter.ValueNames[i]).GetString();
}
logger.Log(logLevel, new EventId(eventId, eventName), exception, formatString, args);
}
else
{
var obj = new LogObject(message, lastFormattedMessage);
logger.Log(logLevel, new EventId(eventId, eventName), obj, exception, LogObject.Callback);
}
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Error processing log entry for {ServiceName}", replicaName);
}
finally
{
scopes.ForEach(d => d.Dispose());
}
});
source.Dynamic.AddCallbackForProviderEvent(MicrosoftExtensionsLoggingProviderName, "FormattedMessage", (traceEvent) =>
{
// Level, FactoryID, LoggerName, EventID, EventName, FormattedMessage
var logLevel = (LogLevel)traceEvent.PayloadByName("Level");
var factoryId = (int)traceEvent.PayloadByName("FactoryID");
var categoryName = (string)traceEvent.PayloadByName("LoggerName");
var eventId = (int)traceEvent.PayloadByName("EventId");
var eventName = (string)traceEvent.PayloadByName("EventName");
var formattedMessage = (string)traceEvent.PayloadByName("FormattedMessage");
if (string.IsNullOrEmpty(formattedMessage))
{
formattedMessage = eventName;
eventName = "";
}
lastFormattedMessage = formattedMessage;
});
}
private void HandleEventCounters(EventPipeEventSource source, IDictionary<string, string> metrics)
{
source.Dynamic.All += traceEvent =>
{
try
{
// Metrics
if (traceEvent.EventName.Equals("EventCounters"))
{
var payloadVal = (IDictionary<string, object>)traceEvent.PayloadValue(0);
var eventPayload = (IDictionary<string, object>)payloadVal["Payload"];
ICounterPayload payload = CounterPayload.FromPayload(eventPayload);
metrics[traceEvent.ProviderName + "/" + payload.Name] = payload.Value;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error processing counter for {ProviderName}:{EventName}", traceEvent.ProviderName, traceEvent.EventName);
}
};
}
private static void HandleDistributedTracingEvents(EventPipeEventSource source, SpanProcessor processor)
{
var activities = new Dictionary<string, ActivityItem>();
source.Dynamic.All += traceEvent =>
{
if (traceEvent.EventName == "Activity1Start/Start")
{
var listenerEventName = (string)traceEvent.PayloadByName("EventName");
if (traceEvent.PayloadByName("Arguments") is IDictionary<string, object>[] arguments)
{
if (TryCreateActivity(arguments, out var item))
{
string method = null;
string path = null;
string host = null;
string pathBase = null;
string queryString = null;
string scheme = null;
foreach (var arg in arguments)
{
var key = (string)arg["Key"];
var value = (string)arg["Value"];
if (key == "Path")
{
path = value;
}
else if (key == "Method")
{
method = value;
}
else if (key == "Host")
{
host = value;
}
else if (key == "PathBase")
{
pathBase = value;
}
else if (key == "Scheme")
{
scheme = value;
}
else if (key == "QueryString")
{
queryString = value;
}
}
item.Name = path;
item.Kind = SpanKind.Server;
item.Attributes[SpanAttributeConstants.HttpUrlKey] = scheme + "://" + host + pathBase + path + queryString;
item.Attributes[SpanAttributeConstants.HttpMethodKey] = method;
item.Attributes[SpanAttributeConstants.HttpPathKey] = path;
activities[item.Id] = item;
}
}
}
if (traceEvent.EventName == "Activity1Stop/Stop")
{
var listenerEventName = (string)traceEvent.PayloadByName("EventName");
if (traceEvent.PayloadByName("Arguments") is IDictionary<string, object>[] arguments)
{
var (activityId, duration) = GetActivityStop(arguments);
int statusCode = 0;
foreach (var arg in arguments)
{
var key = (string)arg["Key"];
var value = (string)arg["Value"];
if (key == "StatusCode")
{
statusCode = int.Parse(value);
}
}
if (activityId != null && activities.TryGetValue(activityId, out var item))
{
item.Attributes[SpanAttributeConstants.HttpStatusCodeKey] = statusCode;
item.EndTime = item.StartTime + duration;
var spanData = new SpanData(item.Name,
new SpanContext(item.TraceId, item.SpanId, ActivityTraceFlags.Recorded),
item.ParentSpanId,
item.Kind,
item.StartTime,
item.Attributes,
Enumerable.Empty<Event>(),
Enumerable.Empty<Link>(),
null,
Status.Ok,
item.EndTime);
processor.OnEnd(spanData);
activities.Remove(activityId);
}
}
}
if (traceEvent.EventName == "Activity2Start/Start")
{
var listenerEventName = (string)traceEvent.PayloadByName("EventName");
if (traceEvent.PayloadByName("Arguments") is IDictionary<string, object>[] arguments)
{
string uri = null;
string method = null;
foreach (var arg in arguments)
{
var key = (string)arg["Key"];
var value = (string)arg["Value"];
if (key == "RequestUri")
{
uri = value;
}
else if (key == "Method")
{
method = value;
}
}
if (TryCreateActivity(arguments, out var item))
{
item.Name = uri;
item.Kind = SpanKind.Client;
item.Attributes[SpanAttributeConstants.HttpUrlKey] = uri;
item.Attributes[SpanAttributeConstants.HttpMethodKey] = method;
activities[item.Id] = item;
}
}
}
if (traceEvent.EventName == "Activity2Stop/Stop")
{
var listenerEventName = (string)traceEvent.PayloadByName("EventName");
if (traceEvent.PayloadByName("Arguments") is IDictionary<string, object>[] arguments)
{
var (activityId, duration) = GetActivityStop(arguments);
if (activityId != null && activities.TryGetValue(activityId, out var item))
{
item.EndTime = item.StartTime + duration;
var spanData = new SpanData(item.Name,
new SpanContext(item.TraceId, item.SpanId, ActivityTraceFlags.Recorded),
item.ParentSpanId,
item.Kind,
item.StartTime,
item.Attributes,
Enumerable.Empty<Event>(),
Enumerable.Empty<Link>(),
null,
Status.Ok,
item.EndTime);
processor.OnEnd(spanData);
activities.Remove(activityId);
}
}
}
};
}
private static (string ActivityId, TimeSpan Duration) GetActivityStop(IDictionary<string, object>[] arguments)
{
var activityId = default(string);
var duration = default(TimeSpan);
foreach (var arg in arguments)
{
var key = (string)arg["Key"];
var value = (string)arg["Value"];
if (key == "ActivityId")
{
activityId = value;
}
else if (key == "ActivityDuration")
{
duration = new TimeSpan(long.Parse(value));
}
}
return (activityId, duration);
}
private static bool TryCreateActivity(IDictionary<string, object>[] arguments, out ActivityItem item)
{
string activityId = null;
string operationName = null;
string spanId = null;
string parentSpanId = null;
string traceId = null;
DateTime startTime = default;
ActivityIdFormat idFormat = default;
foreach (var arg in arguments)
{
var key = (string)arg["Key"];
var value = (string)arg["Value"];
if (key == "ActivityId")
{
activityId = value;
}
else if (key == "ActivityOperationName")
{
operationName = value;
}
else if (key == "ActivitySpanId")
{
spanId = value;
}
else if (key == "ActivityTraceId")
{
traceId = value;
}
else if (key == "ActivityParentSpanId")
{
parentSpanId = value;
}
else if (key == "ActivityStartTime")
{
startTime = new DateTime(long.Parse(value), DateTimeKind.Utc);
}
else if (key == "ActivityIdFormat")
{
idFormat = Enum.Parse<ActivityIdFormat>(value);
}
}
if (string.IsNullOrEmpty(activityId))
{
item = null;
// Not a 3.1 application (we can detect this earlier)
return false;
}
if (idFormat == ActivityIdFormat.Hierarchical)
{
// We need W3C to make it work
item = null;
return false;
}
// This is what open telemetry currently does
// https://github.com/open-telemetry/opentelemetry-dotnet/blob/4ba732af062ddc2759c02aebbc91335aaa3f7173/src/OpenTelemetry.Collector.AspNetCore/Implementation/HttpInListener.cs#L65-L92
item = new ActivityItem()
{
Id = activityId,
Name = operationName,
SpanId = ActivitySpanId.CreateFromString(spanId),
TraceId = ActivityTraceId.CreateFromString(traceId),
ParentSpanId = parentSpanId == "0000000000000000" ? default : ActivitySpanId.CreateFromString(parentSpanId),
StartTime = startTime,
};
return true;
}
// This is the logger factory for application logs. It allows re-routing event pipe collected logs (structured logs)
// to any of the supported sinks, currently (elastic search and app insights)
private void ConfigureLogging(string serviceName, string replicaName, ILoggingBuilder builder)
{
var logProviderKey = _options.LoggingProvider.Key;
var logProviderValue = _options.LoggingProvider.Value;
if (string.Equals(logProviderKey, "elastic", StringComparison.OrdinalIgnoreCase) &&
!string.IsNullOrEmpty(logProviderValue))
{
var loggerConfiguration = new LoggerConfiguration()
.Enrich.WithProperty("Application", serviceName)
.Enrich.WithProperty("Instance", replicaName)
.Enrich.FromLogContext()
.WriteTo.Elasticsearch(logProviderValue);
builder.AddSerilog(loggerConfiguration.CreateLogger());
}
if (string.Equals(logProviderKey, "console", StringComparison.OrdinalIgnoreCase))
{
var loggerConfiguration = new LoggerConfiguration()
.Enrich.WithProperty("Application", serviceName)
.Enrich.WithProperty("Instance", replicaName)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "[{Instance}]: [{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}");
builder.AddSerilog(loggerConfiguration.CreateLogger());
}
if (string.Equals(logProviderKey, "seq", StringComparison.OrdinalIgnoreCase))
{
var loggerConfiguration = new LoggerConfiguration()
.Enrich.WithProperty("Application", serviceName)
.Enrich.WithProperty("Instance", replicaName)
.Enrich.FromLogContext()
.WriteTo.Seq(logProviderValue);
builder.AddSerilog(loggerConfiguration.CreateLogger());
}
if (string.Equals(logProviderKey, "ai", StringComparison.OrdinalIgnoreCase) &&
!string.IsNullOrEmpty(logProviderValue))
{
builder.AddApplicationInsights(logProviderValue);
}
// REVIEW: How are log levels controlled on the outside?
builder.SetMinimumLevel(LogLevel.Information);
}
private SpanExporter CreateSpanExporter(string serviceName, string replicaName)
{
if (string.Equals(_options.DistributedTraceProvider.Key, "zipkin", StringComparison.OrdinalIgnoreCase) &&
!string.IsNullOrEmpty(_options.DistributedTraceProvider.Value))
{
var zipkin = new ZipkinTraceExporter(new ZipkinTraceExporterOptions
{
ServiceName = serviceName,
Endpoint = new Uri($"{_options.DistributedTraceProvider.Value.TrimEnd('/')}/api/v2/spans")
});
return zipkin;
}
// TODO: Support Jaegar
// TODO: Support ApplicationInsights
return new NullExporter();
}
public class NullExporter : SpanExporter
{
public override Task<ExportResult> ExportAsync(IEnumerable<SpanData> batch, CancellationToken cancellationToken)
{
return Task.FromResult(ExportResult.Success);
}
public override Task ShutdownAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
private class ActivityItem
{
public string Id { get; set; }
public string Name { get; set; }
public ActivityTraceId TraceId { get; set; }
public ActivitySpanId SpanId { get; set; }
public Dictionary<string, object> Attributes { get; } = new Dictionary<string, object>();
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public SpanKind Kind { get; set; }
public ActivitySpanId ParentSpanId { get; set; }
}
private class LogActivityItem
{
public Guid ActivityID { get; set; }
public LogObject ScopedObject { get; set; }
public LogActivityItem Parent { get; set; }
}
internal static class SpanAttributeConstants
{
public static readonly string ComponentKey = "component";
public static readonly string HttpMethodKey = "http.method";
public static readonly string HttpStatusCodeKey = "http.status_code";
public static readonly string HttpUserAgentKey = "http.user_agent";
public static readonly string HttpPathKey = "http.path";
public static readonly string HttpHostKey = "http.host";
public static readonly string HttpUrlKey = "http.url";
public static readonly string HttpRouteKey = "http.route";
public static readonly string HttpFlavorKey = "http.flavor";
}
internal sealed class LoggingEventSource
{
/// <summary>
/// This is public from an EventSource consumer point of view, but since these defintions
/// are not needed outside this class
/// </summary>
public static class Keywords
{
/// <summary>
/// Meta events are events about the LoggingEventSource itself (that is they did not come from ILogger
/// </summary>
public const EventKeywords Meta = (EventKeywords)1;
/// <summary>
/// Turns on the 'Message' event when ILogger.Log() is called. It gives the information in a programmatic (not formatted) way
/// </summary>
public const EventKeywords Message = (EventKeywords)2;
/// <summary>
/// Turns on the 'FormatMessage' event when ILogger.Log() is called. It gives the formatted string version of the information.
/// </summary>
public const EventKeywords FormattedMessage = (EventKeywords)4;
/// <summary>
/// Turns on the 'MessageJson' event when ILogger.Log() is called. It gives JSON representation of the Arguments.
/// </summary>
public const EventKeywords JsonMessage = (EventKeywords)8;
}
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.Json;
namespace Micronetes.Hosting.Diagnostics.Logging
{
internal class LogObject : IReadOnlyList<KeyValuePair<string, object>>
{
internal static readonly Func<object, Exception, string> Callback = (state, exception) => ((LogObject)state).ToString();
private readonly string _formattedMessage;
private List<KeyValuePair<string, object>> _items = new List<KeyValuePair<string, object>>();
public LogObject(JsonElement element, string formattedMessage = null)
{
foreach (var item in element.EnumerateObject())
{
switch (item.Value.ValueKind)
{
case JsonValueKind.Undefined:
break;
case JsonValueKind.Object:
break;
case JsonValueKind.Array:
break;
case JsonValueKind.String:
_items.Add(new KeyValuePair<string, object>(item.Name, item.Value.GetString()));
break;
case JsonValueKind.Number:
_items.Add(new KeyValuePair<string, object>(item.Name, item.Value.GetInt32()));
break;
case JsonValueKind.False:
case JsonValueKind.True:
_items.Add(new KeyValuePair<string, object>(item.Name, item.Value.GetBoolean()));
break;
case JsonValueKind.Null:
_items.Add(new KeyValuePair<string, object>(item.Name, null));
break;
default:
break;
}
}
_formattedMessage = formattedMessage;
}
public KeyValuePair<string, object> this[int index] => _items[index];
public int Count => _items.Count;
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
return _items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public override string ToString()
{
return _formattedMessage ?? string.Empty;
}
}
}

Просмотреть файл

@ -0,0 +1,200 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Text;
namespace Micronetes.Hosting.Diagnostics.Logging
{
/// <summary>
/// Formatter to convert the named format items like {NamedformatItem} to <see cref="M:string.Format"/> format.
/// </summary>
internal class LogValuesFormatter
{
private const string NullValue = "(null)";
private static readonly object[] EmptyArray = new object[0];
private static readonly char[] FormatDelimiters = { ',', ':' };
private readonly string _format;
private readonly List<string> _valueNames = new List<string>();
public LogValuesFormatter(string format)
{
OriginalFormat = format;
var sb = new StringBuilder();
var scanIndex = 0;
var endIndex = format.Length;
while (scanIndex < endIndex)
{
var openBraceIndex = FindBraceIndex(format, '{', scanIndex, endIndex);
var closeBraceIndex = FindBraceIndex(format, '}', openBraceIndex, endIndex);
if (closeBraceIndex == endIndex)
{
sb.Append(format, scanIndex, endIndex - scanIndex);
scanIndex = endIndex;
}
else
{
// Format item syntax : { index[,alignment][ :formatString] }.
var formatDelimiterIndex = FindIndexOfAny(format, FormatDelimiters, openBraceIndex, closeBraceIndex);
sb.Append(format, scanIndex, openBraceIndex - scanIndex + 1);
sb.Append(_valueNames.Count.ToString(CultureInfo.InvariantCulture));
_valueNames.Add(format.Substring(openBraceIndex + 1, formatDelimiterIndex - openBraceIndex - 1));
sb.Append(format, formatDelimiterIndex, closeBraceIndex - formatDelimiterIndex + 1);
scanIndex = closeBraceIndex + 1;
}
}
_format = sb.ToString();
}
public string OriginalFormat { get; private set; }
public List<string> ValueNames => _valueNames;
private static int FindBraceIndex(string format, char brace, int startIndex, int endIndex)
{
// Example: {{prefix{{{Argument}}}suffix}}.
var braceIndex = endIndex;
var scanIndex = startIndex;
var braceOccurenceCount = 0;
while (scanIndex < endIndex)
{
if (braceOccurenceCount > 0 && format[scanIndex] != brace)
{
if (braceOccurenceCount % 2 == 0)
{
// Even number of '{' or '}' found. Proceed search with next occurence of '{' or '}'.
braceOccurenceCount = 0;
braceIndex = endIndex;
}
else
{
// An unescaped '{' or '}' found.
break;
}
}
else if (format[scanIndex] == brace)
{
if (brace == '}')
{
if (braceOccurenceCount == 0)
{
// For '}' pick the first occurence.
braceIndex = scanIndex;
}
}
else
{
// For '{' pick the last occurence.
braceIndex = scanIndex;
}
braceOccurenceCount++;
}
scanIndex++;
}
return braceIndex;
}
private static int FindIndexOfAny(string format, char[] chars, int startIndex, int endIndex)
{
var findIndex = format.IndexOfAny(chars, startIndex, endIndex - startIndex);
return findIndex == -1 ? endIndex : findIndex;
}
public string Format(object[] values)
{
if (values != null)
{
for (int i = 0; i < values.Length; i++)
{
values[i] = FormatArgument(values[i]);
}
}
return string.Format(CultureInfo.InvariantCulture, _format, values ?? EmptyArray);
}
internal string Format()
{
return _format;
}
internal string Format(object arg0)
{
return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0));
}
internal string Format(object arg0, object arg1)
{
return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0), FormatArgument(arg1));
}
internal string Format(object arg0, object arg1, object arg2)
{
return string.Format(CultureInfo.InvariantCulture, _format, FormatArgument(arg0), FormatArgument(arg1), FormatArgument(arg2));
}
public KeyValuePair<string, object> GetValue(object[] values, int index)
{
if (index < 0 || index > _valueNames.Count)
{
throw new IndexOutOfRangeException(nameof(index));
}
if (_valueNames.Count > index)
{
return new KeyValuePair<string, object>(_valueNames[index], values[index]);
}
return new KeyValuePair<string, object>("{OriginalFormat}", OriginalFormat);
}
public IEnumerable<KeyValuePair<string, object>> GetValues(object[] values)
{
var valueArray = new KeyValuePair<string, object>[values.Length + 1];
for (var index = 0; index != _valueNames.Count; ++index)
{
valueArray[index] = new KeyValuePair<string, object>(_valueNames[index], values[index]);
}
valueArray[valueArray.Length - 1] = new KeyValuePair<string, object>("{OriginalFormat}", OriginalFormat);
return valueArray;
}
private object FormatArgument(object value)
{
if (value == null)
{
return NullValue;
}
// since 'string' implements IEnumerable, special case it
if (value is string)
{
return value;
}
// if the value implements IEnumerable, build a comma separated string.
var enumerable = value as IEnumerable;
if (enumerable != null)
{
return string.Join(", ", enumerable.Cast<object>().Select(o => o ?? NullValue));
}
return value;
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
using System;
using System.Collections;
using System.Runtime.Serialization;
using System.Text.Json;
namespace Micronetes.Hosting.Diagnostics.Logging
{
internal class LoggerException : Exception
{
private readonly JsonElement _exceptionMessage;
public LoggerException(JsonElement exceptionMessage)
{
_exceptionMessage = exceptionMessage;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("ClassName", _exceptionMessage.GetProperty("TypeName").GetString(), typeof(string)); // Do not rename (binary serialization)
info.AddValue("Message", Message, typeof(string)); // Do not rename (binary serialization)
info.AddValue("Data", Data, typeof(IDictionary)); // Do not rename (binary serialization)
info.AddValue("InnerException", null, typeof(Exception)); // Do not rename (binary serialization)
info.AddValue("HelpURL", null, typeof(string)); // Do not rename (binary serialization)
info.AddValue("StackTraceString", StackTrace, typeof(string)); // Do not rename (binary serialization)
info.AddValue("RemoteStackTraceString", StackTrace, typeof(string)); // Do not rename (binary serialization)
info.AddValue("RemoteStackIndex", 0, typeof(int)); // Do not rename (binary serialization)
info.AddValue("ExceptionMethod", null, typeof(string)); // Do not rename (binary serialization)
info.AddValue("HResult", int.Parse(_exceptionMessage.GetProperty("HResult").GetString())); // Do not rename (binary serialization)
info.AddValue("Source", Source, typeof(string)); // Do not rename (binary serialization
info.AddValue("WatsonBuckets", null, typeof(byte[])); // Do not rename (binary serialization)
}
public override string Message => _exceptionMessage.GetProperty("Message").GetString();
public override string StackTrace => _exceptionMessage.GetProperty("VerboseMessage").GetString();
public override string ToString()
{
return _exceptionMessage.GetProperty("VerboseMessage").GetString();
}
}
}

Просмотреть файл

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Micronetes.Hosting.Diagnostics.Metrics
{
internal class CounterPayload : ICounterPayload
{
public CounterPayload(IDictionary<string, object> payloadFields)
{
Name = payloadFields["Name"].ToString();
Value = payloadFields["Mean"].ToString();
}
public string Name { get; }
public string Value { get; }
public static ICounterPayload FromPayload(IDictionary<string, object> eventPayload)
{
if (eventPayload.ContainsKey("CounterType"))
{
return eventPayload["CounterType"].Equals("Sum") ? (ICounterPayload)new IncrementingCounterPayload(eventPayload) : (ICounterPayload)new CounterPayload(eventPayload);
}
return eventPayload.Count == 6 ? (ICounterPayload)new IncrementingCounterPayload(eventPayload) : (ICounterPayload)new CounterPayload(eventPayload);
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Micronetes.Hosting.Diagnostics.Metrics
{
internal interface ICounterPayload
{
public string Name { get; }
public string Value { get; }
}
}

Просмотреть файл

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Micronetes.Hosting.Diagnostics.Metrics
{
internal class IncrementingCounterPayload : ICounterPayload
{
public IncrementingCounterPayload(IDictionary<string, object> payloadFields)
{
Name = payloadFields["Name"].ToString();
Value = payloadFields["Increment"].ToString();
}
public string Name { get; }
public string Value { get; }
}
}

Просмотреть файл

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Description>Diagnostics collector and exporter for .NET Core applications.</Description>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.12.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.49" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.61701" />
<PackageReference Include="OpenTelemetry" Version="0.2.0-alpha.173" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="0.2.0-alpha.173" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Micronetes.Hosting.Runtime
{
// This exists solely as a way to locate this dll
public class HostingRuntimeHelpers
{
}
}

Просмотреть файл

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Description>Runtime helpers for m8s host platform</Description>
<Nullable>disable</Nullable>
</PropertyGroup>
</Project>

Просмотреть файл

@ -0,0 +1,24 @@
using System;
using System.Diagnostics;
using System.Threading;
/// <summary>
/// Startup hooks are pieces of code that will run before a users program main executes
/// See: https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/host-startup-hook.md
/// The type must be named StartupHook without any namespace, and should be internal.
/// </summary>
internal class StartupHook
{
/// <summary>
/// Startup hooks are pieces of code that will run before a users program main executes
/// See: https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/host-startup-hook.md
/// </summary>
public static void Initialize()
{
Console.WriteLine("Waiting for debugger to attach...");
while (!Debugger.IsAttached)
{
Thread.Sleep(1000);
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Micronetes.Hosting.Model;
namespace Micronetes.Hosting
{
public class AggregateApplicationProcessor : IApplicationProcessor
{
private readonly IEnumerable<IApplicationProcessor> _applicationProcessors;
public AggregateApplicationProcessor(IEnumerable<IApplicationProcessor> applicationProcessors)
{
_applicationProcessors = applicationProcessors;
}
public async Task StartAsync(Application application)
{
foreach (var processor in _applicationProcessors)
{
await processor.StartAsync(application);
}
}
public async Task StopAsync(Application application)
{
// Shutdown in the opposite order
foreach (var processor in _applicationProcessors.Reverse())
{
await processor.StopAsync(application);
}
}
}
}

Просмотреть файл

@ -0,0 +1,10 @@
<Router AppAssembly="@typeof(MicronetesHost).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

Просмотреть файл

@ -0,0 +1,104 @@
@page "/"
@inject Application application
@implements IDisposable
<h1>Services</h1>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Source</th>
<th>Bindings</th>
<th>Replicas</th>
<th>Restarts</th>
<th>Logs</th>
</tr>
</thead>
<tbody>
@foreach (var service in application.Services.Values)
{
var logsPath = $"logs/{service.Description.Name}";
var servicePath = $"services/{service.Description.Name}";
<tr @key="service.Description.Name">
<td><a href="@servicePath">@service.Description.Name</a></td>
<td>
@service.ServiceType
</td>
<td>
@if (service.Description.Project != null)
{
<p>@service.Description.Project</p>
}
else if (service.Description.DockerImage != null)
{
<p>@service.Description.DockerImage</p>
}
</td>
<td>
@if (service.Description.Bindings.Any())
{
foreach (var b in service.Description.Bindings)
{
if (b.Port != null)
{
if (b.Protocol == null || b.Protocol == "http" || b.Protocol == "https")
{
var url = GetUrl(b);
<span><a href="@url" target="_blank">@url</a></span>
}
else
{
<span>@GetUrl(b)</span>
}
}
else
{
<span>@b.ConnectionString</span>
}
}
}
else
{
<p>none</p>
}
</td>
<td>@service.Replicas.Count/@service.Description.Replicas</td>
<td>@service.Restarts</td>
<td>
<NavLink href="@logsPath">View</NavLink>
</td>
</tr>
}
</tbody>
</table>
@code {
private List<IDisposable> _subscriptions = new List<IDisposable>();
string GetUrl(ServiceBinding b)
{
return $"{(b.Protocol ?? "http")}://{b.Host ?? "localhost"}:{b.Port}";
}
protected override void OnInitialized()
{
foreach (var a in application.Services.Values)
{
_subscriptions.Add(a.ReplicaEvents.Subscribe(OnReplicaChanged));
}
base.OnInitialized();
}
private void OnReplicaChanged(ReplicaEvent replicaEvent)
{
InvokeAsync(() => StateHasChanged());
}
void IDisposable.Dispose()
{
_subscriptions.ForEach(d => d.Dispose());
}
}

Просмотреть файл

@ -0,0 +1,55 @@
@page "/logs/{ServiceName}"
@inject Application application
@implements IDisposable
<h3>Logs for @ServiceName</h3>
@if (ApplicationLogs == null)
{
<span>Unknown service @ServiceName</span>
}
else
{
<div style="overflow-y: scroll;position: absolute;height: 84%; width:75%; color:white;background-color:black;padding:10px">
@foreach (var log in ApplicationLogs)
{
<div @key="@log.Id" style="width:100%">@log.Text</div>
}
</div>
}
@code {
[Parameter]
public string ServiceName { get; set; }
public List<(string Text, int Id)> ApplicationLogs { get; set; }
private IDisposable _subscription;
protected override void OnInitialized()
{
// TODO: handle this returning false
if (application.Services.TryGetValue(ServiceName, out var service))
{
ApplicationLogs = service.CachedLogs.Select((item, index) => (item, index)).ToList();
var count = ApplicationLogs.Count;
_subscription = service.Logs.Subscribe(log =>
{
count++;
InvokeAsync(() =>
{
ApplicationLogs.Add((log, count));
StateHasChanged();
});
});
}
base.OnInitialized();
}
void IDisposable.Dispose()
{
_subscription?.Dispose();
}
}

Просмотреть файл

@ -0,0 +1,35 @@
@page "/services/{ServiceName}"
@inject Application application
@if (Service == null)
{
<span>Unknown service @ServiceName</span>
}
else
{
<h3>@Service.Description.Name</h3>
switch (Service.ServiceType)
{
case ServiceType.Container:
break;
case ServiceType.Executable:
break;
case ServiceType.Project:
break;
}
}
@code {
private Service _service;
[Parameter]
public string ServiceName { get; set; }
public Service Service => _service;
protected override void OnInitialized()
{
application.Services.TryGetValue(ServiceName, out _service);
}
}

Просмотреть файл

@ -0,0 +1,36 @@
@page "/"
@namespace Micronetes.Hosting.Dashboard.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Micronetes Dashboard</title>
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,15 @@
@inherits LayoutComponentBase
<div class="sidebar">
<NavMenu />
</div>
<div class="main">
<div class="top-row top-nav-item nav-item px-4">
<a href="https://github.com/davidfowl/Micronetes" target="_blank">About</a>
</div>
<div class="content px-4">
@Body
</div>
</div>

Просмотреть файл

@ -0,0 +1,30 @@
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">
<img src="img/circle-icons-shipwheel.svg" width="30" height="30" class="d-inline-block align-top" alt="Ship Wheel">
Micronetes Dashboard
</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
</ul>
</div>
@code {
private bool collapseNavMenu = true;
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}

Просмотреть файл

@ -0,0 +1,11 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop
@using Micronetes.Hosting
@using Micronetes.Hosting.Dashboard.Shared
@using Micronetes.Hosting.Dashboard.Pages
@using Micronetes.Hosting.Model

Просмотреть файл

@ -0,0 +1,272 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Micronetes.Hosting.Model;
using Microsoft.Extensions.Logging;
namespace Micronetes.Hosting
{
public class DockerRunner : IApplicationProcessor
{
private readonly ILogger _logger;
private readonly Lazy<Task<bool>> _dockerInstalled = new Lazy<Task<bool>>(DetectDockerInstalled);
public DockerRunner(ILogger logger)
{
_logger = logger;
}
public Task StartAsync(Application application)
{
var tasks = new Task[application.Services.Count];
var index = 0;
foreach (var s in application.Services)
{
tasks[index++] = s.Value.Description.External ? Task.CompletedTask : StartContainerAsync(application, s.Value);
}
return Task.WhenAll(tasks);
}
public Task StopAsync(Application application)
{
var services = application.Services;
var index = 0;
var tasks = new Task[services.Count];
foreach (var s in services.Values)
{
var state = s;
tasks[index++] = StopContainerAsync(state);
}
return Task.WhenAll(tasks);
}
private async Task StartContainerAsync(Application application, Service service)
{
if (service.Description.DockerImage == null)
{
return;
}
if (!await _dockerInstalled.Value)
{
_logger.LogError("Unable to start docker container for service {ServiceName}, Docker is not installed.", service.Description.Name);
service.Logs.OnNext($"Unable to start docker container for service {service.Description.Name}, Docker is not installed.");
return;
}
var serviceDescription = service.Description;
var environmentArguments = "";
var dockerInfo = new DockerInformation()
{
Tasks = new Task[service.Description.Replicas.Value]
};
async Task RunDockerContainer(IEnumerable<(int Port, int? InternalPort, int BindingPort, string Protocol)> ports)
{
var hasPorts = ports.Any();
var replica = service.Description.Name.ToLower() + "_" + Guid.NewGuid().ToString().Substring(0, 10).ToLower();
var status = new DockerStatus(service, replica);
service.Replicas[replica] = status;
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Added, status));
var environment = new Dictionary<string, string>
{
// Default to development environment
["DOTNET_ENVIRONMENT"] = "Development",
// Remove the color codes from the console output
["DOTNET_LOGGING__CONSOLE__DISABLECOLORS"] = "true"
};
var portString = "";
if (hasPorts)
{
status.Ports = ports.Select(p => p.Port);
portString = string.Join(" ", ports.Select(p => $"-p {p.Port}:{p.InternalPort ?? p.Port}"));
foreach (var p in ports)
{
environment[$"{p.Protocol?.ToUpper() ?? "HTTP"}_PORT"] = p.BindingPort.ToString();
}
}
application.PopulateEnvironment(service, (key, value) => environment[key] = value, "host.docker.internal");
environment["APP_INSTANCE"] = replica;
foreach (var pair in environment)
{
environmentArguments += $"-e {pair.Key}={pair.Value} ";
}
var command = $"run -d {environmentArguments} {portString} --name {replica} --restart=unless-stopped {service.Description.DockerImage} {service.Description.Args ?? ""}";
_logger.LogInformation("Running docker command {Command}", command);
service.Logs.OnNext($"[{replica}]: {command}");
status.DockerCommand = command;
var result = await ProcessUtil.RunAsync(
"docker",
command,
throwOnError: false,
cancellationToken: dockerInfo.StoppingTokenSource.Token,
outputDataReceived: data => service.Logs.OnNext($"[{replica}]: {data}"));
if (result.ExitCode != 0)
{
_logger.LogError("docker run failed for {ServiceName} with exit code {ExitCode}:" + result.StandardError, service.Description.Name, result.ExitCode);
service.Replicas.TryRemove(replica, out _);
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Removed, status));
PrintStdOutAndErr(service, replica, result);
return;
}
var containerId = result.StandardOutput.Trim();
// There's a race condition that sometimes makes us miss the output
// so keep trying to get the container id
while (string.IsNullOrEmpty(containerId))
{
// Try to get the ID of the container
result = await ProcessUtil.RunAsync("docker", $"ps --no-trunc -f name={replica} --format " + "{{.ID}}");
containerId = result.ExitCode == 0 ? result.StandardOutput.Trim() : null;
}
var shortContainerId = containerId.Substring(0, Math.Min(12, containerId.Length));
status.ContainerId = shortContainerId;
_logger.LogInformation("Running container {ContainerName} with ID {ContainerId}", replica, shortContainerId);
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Started, status));
_logger.LogInformation("Collecting docker logs for {ContainerName}.", replica);
await ProcessUtil.RunAsync("docker", $"logs -f {containerId}",
outputDataReceived: data => service.Logs.OnNext($"[{replica}]: {data}"),
onStart: pid =>
{
status.DockerLogsPid = pid;
},
throwOnError: false,
cancellationToken: dockerInfo.StoppingTokenSource.Token);
_logger.LogInformation("docker logs collection for {ContainerName} complete with exit code {ExitCode}", replica, result.ExitCode);
// Docker has a tendency to hang so we're going to timeout this shutdown process
var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
_logger.LogInformation("Stopping container {ContainerName} with ID {ContainerId}", replica, shortContainerId);
result = await ProcessUtil.RunAsync("docker", $"stop {containerId}", throwOnError: false, cancellationToken: timeoutCts.Token);
PrintStdOutAndErr(service, replica, result);
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Stopped, status));
_logger.LogInformation("Stopped container {ContainerName} with ID {ContainerId} exited with {ExitCode}", replica, shortContainerId, result.ExitCode);
result = await ProcessUtil.RunAsync("docker", $"rm {containerId}", throwOnError: false, cancellationToken: timeoutCts.Token);
PrintStdOutAndErr(service, replica, result);
_logger.LogInformation("Removed container {ContainerName} with ID {ContainerId} exited with {ExitCode}", replica, shortContainerId, result.ExitCode);
service.Replicas.TryRemove(replica, out _);
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Removed, status));
};
if (serviceDescription.Bindings.Count > 0)
{
// Each replica is assigned a list of internal ports, one mapped to each external
// port
for (int i = 0; i < serviceDescription.Replicas; i++)
{
var ports = new List<(int, int?, int, string)>();
foreach (var binding in serviceDescription.Bindings)
{
if (binding.Port == null)
{
continue;
}
ports.Add((service.PortMap[binding.Port.Value][i], binding.InternalPort, binding.Port.Value, binding.Protocol));
}
dockerInfo.Tasks[i] = RunDockerContainer(ports);
}
}
else
{
for (int i = 0; i < service.Description.Replicas; i++)
{
dockerInfo.Tasks[i] = RunDockerContainer(Enumerable.Empty<(int, int?, int, string)>());
}
}
service.Items[typeof(DockerInformation)] = dockerInfo;
}
private static void PrintStdOutAndErr(Service service, string replica, ProcessResult result)
{
if (result.ExitCode != 0)
{
if (result.StandardOutput != null)
{
service.Logs.OnNext($"[{replica}]: {result.StandardOutput}");
}
if (result.StandardError != null)
{
service.Logs.OnNext($"[{replica}]: {result.StandardError}");
}
}
}
private async Task StopContainerAsync(Service service)
{
if (service.Items.TryGetValue(typeof(DockerInformation), out var value) && value is DockerInformation di)
{
di.StoppingTokenSource.Cancel();
await Task.WhenAll(di.Tasks);
}
}
private static async Task<bool> DetectDockerInstalled()
{
// Detect Docker installation
try
{
await ProcessUtil.RunAsync("docker", "version", throwOnError: false);
return true;
}
catch (Exception)
{
// Unfortunately, process throws
return false;
}
}
private class DockerInformation
{
public Task[] Tasks { get; set; }
public CancellationTokenSource StoppingTokenSource { get; set; } = new CancellationTokenSource();
}
}
}

Просмотреть файл

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Micronetes.Hosting.Diagnostics;
using Micronetes.Hosting.Model;
using Microsoft.Extensions.Logging;
namespace Micronetes.Hosting
{
public class EventPipeDiagnosticsRunner : IApplicationProcessor
{
private readonly ILogger _logger;
private readonly DiagnosticsCollector _diagnosticsCollector;
public EventPipeDiagnosticsRunner(ILogger logger, DiagnosticsCollector diagnosticsCollector)
{
_logger = logger;
_diagnosticsCollector = diagnosticsCollector;
}
public Task StartAsync(Application application)
{
foreach (var service in application.Services.Values)
{
if (service.Description.External)
{
continue;
}
service.Items[typeof(Subscription)] = service.ReplicaEvents.Subscribe(OnReplicaChanged);
}
return Task.CompletedTask;
}
public Task StopAsync(Application application)
{
foreach (var service in application.Services.Values)
{
if (service.Items.TryGetValue(typeof(Subscription), out var item) && item is IDisposable disposable)
{
disposable.Dispose();
}
}
return Task.CompletedTask;
}
private void OnReplicaChanged(ReplicaEvent replicaEvent)
{
var replica = replicaEvent.Replica;
if (!(replica is ProcessStatus process))
{
// This temporarily only works for processes launched
return;
}
switch (replicaEvent.State)
{
case ReplicaState.Started:
{
var cts = new CancellationTokenSource();
var state = new DiagnosticsState
{
StoppingTokenSource = cts,
Thread = new Thread(() =>
{
// TODO: Finding the application name requires msbuild knowledge
_diagnosticsCollector.ProcessEvents(Path.GetFileNameWithoutExtension(process.Service.Status.ProjectFilePath),
process.Service.Description.Name,
process.Pid.Value,
replica.Name,
replica.Metrics,
cts.Token);
})
};
replica.Items[typeof(DiagnosticsState)] = state;
state.Thread.Start();
}
break;
case ReplicaState.Stopped:
{
if (replica.Items.TryGetValue(typeof(DiagnosticsState), out var item) && item is DiagnosticsState state)
{
state.StoppingTokenSource.Cancel();
state.Thread.Join();
}
}
break;
default:
break;
}
}
// Used a lookup key for state
private class Subscription { }
private class DiagnosticsState
{
public Thread Thread { get; set; }
public CancellationTokenSource StoppingTokenSource { get; set; } = new CancellationTokenSource();
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
using System.Threading.Tasks;
using Micronetes.Hosting.Model;
namespace Micronetes.Hosting
{
public interface IApplicationProcessor
{
Task StartAsync(Application application);
Task StopAsync(Application application);
}
}

Просмотреть файл

@ -0,0 +1,16 @@
namespace Micronetes.Hosting
{
internal class ProcessResult
{
public ProcessResult(string standardOutput, string standardError, int exitCode)
{
StandardOutput = standardOutput;
StandardError = standardError;
ExitCode = exitCode;
}
public string StandardOutput { get; }
public string StandardError { get; }
public int ExitCode { get; }
}
}

Просмотреть файл

@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Mono.Unix.Native;
namespace Micronetes.Hosting
{
internal static class ProcessUtil
{
public static async Task<ProcessResult> RunAsync(
string filename,
string arguments,
string workingDirectory = null,
bool throwOnError = true,
IDictionary<string, string> environmentVariables = null,
Action<string> outputDataReceived = null,
Action<string> errorDataReceived = null,
Action<int> onStart = null,
CancellationToken cancellationToken = default)
{
using var process = new Process()
{
StartInfo =
{
FileName = filename,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
},
EnableRaisingEvents = true
};
if (workingDirectory != null)
{
process.StartInfo.WorkingDirectory = workingDirectory;
}
if (environmentVariables != null)
{
foreach (var kvp in environmentVariables)
{
process.StartInfo.Environment.Add(kvp);
}
}
var outputBuilder = new StringBuilder();
process.OutputDataReceived += (_, e) =>
{
if (e.Data != null)
{
if (outputDataReceived != null)
{
outputDataReceived.Invoke(e.Data);
}
else
{
outputBuilder.AppendLine(e.Data);
}
}
};
var errorBuilder = new StringBuilder();
process.ErrorDataReceived += (_, e) =>
{
if (e.Data != null)
{
if (errorDataReceived != null)
{
errorDataReceived.Invoke(e.Data);
}
else if (outputDataReceived != null)
{
outputDataReceived.Invoke(e.Data);
}
else
{
errorBuilder.AppendLine(e.Data);
}
}
};
var processLifetimeTask = new TaskCompletionSource<ProcessResult>();
process.Exited += (_, e) =>
{
if (throwOnError && process.ExitCode != 0)
{
processLifetimeTask.TrySetException(new InvalidOperationException($"Command {filename} {arguments} returned exit code {process.ExitCode}"));
}
else
{
processLifetimeTask.TrySetResult(new ProcessResult(outputBuilder.ToString(), errorBuilder.ToString(), process.ExitCode));
}
};
process.Start();
onStart?.Invoke(process.Id);
process.BeginOutputReadLine();
process.BeginErrorReadLine();
var cancelledTcs = new TaskCompletionSource<object>();
using var _ = cancellationToken.Register(() => cancelledTcs.TrySetResult(null));
var result = await Task.WhenAny(processLifetimeTask.Task, cancelledTcs.Task);
if (result == cancelledTcs.Task)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Syscall.kill(process.Id, Signum.SIGINT);
var cancel = new CancellationTokenSource();
await Task.WhenAny(processLifetimeTask.Task, Task.Delay(TimeSpan.FromSeconds(5), cancel.Token));
cancel.Cancel();
}
if (!process.HasExited)
{
process.CloseMainWindow();
if (!process.HasExited)
{
process.Kill();
}
}
}
return await processLifetimeTask.Task;
}
}
}

Просмотреть файл

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Description>Orchestration host APIs.</Description>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="wwwroot\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Bedrock.Framework" Version="0.1.38-alpha.gd25d5b37ad" />
<PackageReference Include="FeatherHttp" Version="0.1.42-alpha.gf06a8747e7" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.0" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Sln" Version="0.3.0" />
<PackageReference Include="YamlDotNet" Version="8.0.0" />
<PackageReference Include="System.Reactive" Version="4.3.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Micronetes.Hosting.Diagnostics\Micronetes.Hosting.Diagnostics.csproj" />
<ProjectReference Include="..\Micronetes.Hosting.Runtime\Micronetes.Hosting.Runtime.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,173 @@
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Micronetes.Hosting.Model;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace Micronetes.Hosting
{
public class MicronetesApi
{
private readonly JsonSerializerOptions _options;
public MicronetesApi()
{
_options = new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
};
_options.Converters.Add(ReplicaStatus.JsonConverter);
}
public void MapRoutes(IEndpointRouteBuilder endpoints)
{
endpoints.MapGet("/api/v1", ServiceIndex);
endpoints.MapGet("/api/v1/services", Services);
endpoints.MapGet("/api/v1/services/{name}", Service);
endpoints.MapGet("/api/v1/logs/{name}", Logs);
endpoints.MapGet("/api/v1/metrics", AllMetrics);
endpoints.MapGet("/api/v1/metrics/{name}", Metics);
}
private Task ServiceIndex(HttpContext context)
{
context.Response.ContentType = "application/json";
return JsonSerializer.SerializeAsync(context.Response.Body, new[]
{
$"{context.Request.Scheme}://{context.Request.Host}/api/v1/services",
$"{context.Request.Scheme}://{context.Request.Host}/api/v1/logs/{{service}}",
$"{context.Request.Scheme}://{context.Request.Host}/api/v1/metrics",
$"{context.Request.Scheme}://{context.Request.Host}/api/v1/metrics/{{service}}",
},
_options);
}
private async Task Services(HttpContext context)
{
var app = context.RequestServices.GetRequiredService<Application>();
context.Response.ContentType = "application/json";
var services = app.Services.OrderBy(s => s.Key).Select(s => s.Value);
await JsonSerializer.SerializeAsync(context.Response.Body, services, _options);
}
private async Task Service(HttpContext context)
{
var app = context.RequestServices.GetRequiredService<Application>();
var name = (string)context.Request.RouteValues["name"];
context.Response.ContentType = "application/json";
if (!app.Services.TryGetValue(name, out var service))
{
context.Response.StatusCode = 404;
await JsonSerializer.SerializeAsync(context.Response.Body, new
{
message = $"Unknown service {name}"
},
_options);
return;
}
await JsonSerializer.SerializeAsync(context.Response.Body, service, _options);
}
private async Task Logs(HttpContext context)
{
var app = context.RequestServices.GetRequiredService<Application>();
var name = (string)context.Request.RouteValues["name"];
context.Response.ContentType = "application/json";
if (!app.Services.TryGetValue(name, out var service))
{
context.Response.StatusCode = 404;
await JsonSerializer.SerializeAsync(context.Response.Body, new
{
message = $"Unknown service {name}"
},
_options);
return;
}
await JsonSerializer.SerializeAsync(context.Response.Body, service.CachedLogs, _options);
}
private async Task AllMetrics(HttpContext context)
{
var app = context.RequestServices.GetRequiredService<Application>();
var sb = new StringBuilder();
foreach (var s in app.Services.OrderBy(s => s.Key))
{
sb.AppendLine($"# {s.Key}");
foreach (var replica in s.Value.Replicas)
{
foreach (var metric in replica.Value.Metrics)
{
sb.Append(metric.Key);
sb.Append("{");
sb.Append($"service=\"{s.Key}\",");
sb.Append($"instance=\"{replica.Key}\"");
sb.Append("}");
sb.Append(" ");
sb.Append(metric.Value);
sb.AppendLine();
}
}
sb.AppendLine();
}
await context.Response.WriteAsync(sb.ToString());
}
private async Task Metics(HttpContext context)
{
var app = context.RequestServices.GetRequiredService<Application>();
var sb = new StringBuilder();
var name = (string)context.Request.RouteValues["name"];
context.Response.ContentType = "application/json";
if (!app.Services.TryGetValue(name, out var service))
{
context.Response.StatusCode = 404;
await JsonSerializer.SerializeAsync(context.Response.Body, new
{
message = $"Unknown service {name}"
},
_options);
return;
}
foreach (var replica in service.Replicas)
{
foreach (var metric in replica.Value.Metrics)
{
sb.Append(metric.Key);
sb.Append("{");
sb.Append($"instance=\"{replica.Key}\"");
sb.Append("}");
sb.Append(" ");
sb.Append(metric.Value);
sb.AppendLine();
}
}
await context.Response.WriteAsync(sb.ToString());
}
}
}

Просмотреть файл

@ -0,0 +1,116 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Micronetes.Hosting.Diagnostics;
using Micronetes.Hosting.Model;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Filters;
namespace Micronetes.Hosting
{
public class MicronetesHost
{
public static async Task RunAsync(Application application, string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Logging for this application
builder.Host.UseSerilog((context, configuration) => configuration
.MinimumLevel.Verbose()
.Filter.ByExcluding(Matching.FromSource("Microsoft"))
.Enrich
.FromLogContext()
.WriteTo
.Console()
);
builder.Services.AddRazorPages(o => o.RootDirectory = "/Dashboard/Pages");
builder.Services.AddServerSideBlazor();
builder.Services.AddOptions<StaticFileOptions>()
.PostConfigure(o =>
{
var fileProvider = new ManifestEmbeddedFileProvider(typeof(MicronetesHost).Assembly, "wwwroot");
// Make sure we don't remove the existing file providers (blazor needs this)
o.FileProvider = new CompositeFileProvider(o.FileProvider, fileProvider);
});
builder.Services.AddSingleton(application);
using var app = builder.Build();
var port = app.Configuration["port"] ?? "0";
app.Listen($"http://127.0.0.1:{port}");
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseRouting();
var api = new MicronetesApi();
api.MapRoutes(app);
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
var logger = app.Logger;
logger.LogInformation("Executing application from {Source}", application.Source);
var lifetime = app.ApplicationLifetime;
var configuration = app.Configuration;
var diagnosticOptions = DiagnosticOptions.FromConfiguration(configuration);
var diagnosticsCollector = new DiagnosticsCollector(logger, diagnosticOptions);
// Print out what providers were selected and their values
diagnosticOptions.DumpDiagnostics(logger);
var processor = new AggregateApplicationProcessor(new IApplicationProcessor[] {
new EventPipeDiagnosticsRunner(logger, diagnosticsCollector),
new ProxyService(logger),
new DockerRunner(logger),
new ProcessRunner(logger, ProcessRunnerOptions.FromArgs(args)),
});
await app.StartAsync();
logger.LogInformation("Dashboard running on {Address}", app.Addresses.First());
try
{
await processor.StartAsync(application);
}
catch (Exception ex)
{
logger.LogError(0, ex, "Failed to launch application");
}
var waitForStop = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
lifetime.ApplicationStopping.Register(obj => waitForStop.TrySetResult(null), null);
await waitForStop.Task;
logger.LogInformation("Shutting down...");
try
{
await processor.StopAsync(application);
}
finally
{
// Stop the host after everything else has been shutdown
await app.StopAsync();
}
}
}
}

Просмотреть файл

@ -0,0 +1,258 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Microsoft.Build.Construction;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace Micronetes.Hosting.Model
{
public class Application
{
public string ContextDirectory { get; set; } = Directory.GetCurrentDirectory();
public string Source { get; set; }
public Application(IEnumerable<ServiceDescription> services)
{
var map = new Dictionary<string, Service>();
// TODO: Do validation here
foreach (var s in services)
{
s.Replicas ??= 1;
map[s.Name] = new Service { Description = s };
}
Services = map;
}
public static Application FromYaml(string path)
{
var fullPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), path));
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var descriptions = deserializer.Deserialize<ServiceDescription[]>(new StringReader(File.ReadAllText(path)));
var contextDirectory = Path.GetDirectoryName(fullPath);
foreach (var d in descriptions)
{
if (d.Project == null)
{
continue;
}
// Try to populate more from launch settings
var projectFilePath = Path.GetFullPath(Path.Combine(contextDirectory, d.Project));
if (!TryGetLaunchSettings(projectFilePath, out var projectSettings))
{
continue;
}
PopulateFromLaunchSettings(d, projectSettings);
}
return new Application(descriptions)
{
Source = fullPath,
// Use the file location as the context when loading from a file
ContextDirectory = contextDirectory
};
}
public static Application FromProject(string path)
{
var fullPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), path));
var projectDescription = CreateDescriptionFromProject(fullPath);
return new Application(projectDescription == null ? new ServiceDescription[0] : new ServiceDescription[] { projectDescription })
{
Source = fullPath,
ContextDirectory = Path.GetDirectoryName(fullPath)
};
}
private static ServiceDescription CreateDescriptionFromProject(string fullPath)
{
if (!TryGetLaunchSettings(fullPath, out var projectSettings))
{
return null;
}
var projectDescription = new ServiceDescription
{
Name = Path.GetFileNameWithoutExtension(fullPath).ToLower(),
Project = fullPath
};
PopulateFromLaunchSettings(projectDescription, projectSettings);
return projectDescription;
}
private static void PopulateFromLaunchSettings(ServiceDescription projectDescription, JsonElement projectSettings)
{
if (projectDescription.Bindings.Count == 0 && projectSettings.TryGetProperty("applicationUrl", out var applicationUrls))
{
var addresses = applicationUrls.GetString()?.Split(';');
foreach (var address in addresses)
{
var uri = new Uri(address);
projectDescription.Bindings.Add(new ServiceBinding
{
Port = uri.Port,
Protocol = uri.Scheme
});
}
}
if (projectDescription.Configuration.Count == 0 && projectSettings.TryGetProperty("environmentVariables", out var environmentVariables))
{
foreach (var envVar in environmentVariables.EnumerateObject())
{
projectDescription.Configuration.Add(new ConfigurationSource
{
Name = envVar.Name,
Value = envVar.Value.GetString()
});
}
}
if (projectDescription.Replicas == null && projectSettings.TryGetProperty("replicas", out var replicasElement))
{
projectDescription.Replicas = replicasElement.GetInt32();
}
}
public static Application FromSolution(string path)
{
var fullPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), path));
var solution = SolutionFile.Parse(fullPath);
var descriptions = new List<ServiceDescription>();
foreach (var project in solution.ProjectsInOrder)
{
if (project.ProjectType != SolutionProjectType.KnownToBeMSBuildFormat)
{
continue;
}
var projectFilePath = project.AbsolutePath.Replace('\\', Path.DirectorySeparatorChar);
var extension = Path.GetExtension(projectFilePath).ToLower();
switch (extension)
{
case ".csproj":
case ".fsproj":
break;
default:
continue;
}
var description = CreateDescriptionFromProject(projectFilePath);
if (description != null)
{
descriptions.Add(description);
}
}
return new Application(descriptions)
{
Source = fullPath,
ContextDirectory = Path.GetDirectoryName(fullPath)
};
}
public Dictionary<string, Service> Services { get; }
internal void PopulateEnvironment(Service service, Action<string, string> set, string defaultHost = "localhost")
{
if (service.Description.Configuration != null)
{
// Inject normal configuration
foreach (var pair in service.Description.Configuration)
{
set(pair.Name, pair.Value);
}
}
void SetBinding(string serviceName, ServiceBinding b)
{
var configName = "";
var envName = "";
if (string.IsNullOrEmpty(b.Name))
{
configName = serviceName;
envName = serviceName;
}
else
{
configName = $"{serviceName.ToUpper()}__{b.Name.ToUpper()}";
envName = $"{serviceName.ToUpper()}_{b.Name.ToUpper()}";
}
if (!string.IsNullOrEmpty(b.ConnectionString))
{
// Special case for connection strings
set($"CONNECTIONSTRING__{configName}", b.ConnectionString);
}
if (!string.IsNullOrEmpty(b.Protocol))
{
// IConfiguration specific (double underscore ends up telling the configuration provider to use it as a separator)
set($"SERVICE__{configName}__PROTOCOL", b.Protocol);
set($"{envName}_SERVICE_PROTOCOL", b.Protocol);
}
if (b.Port != null)
{
set($"SERVICE__{configName}__PORT", b.Port.ToString());
set($"{envName}_SERVICE_PORT", b.Port.ToString());
}
set($"SERVICE__{configName}__HOST", b.Host ?? defaultHost);
set($"{envName}_SERVICE_HOST", b.Host ?? defaultHost);
}
// Inject dependency information
foreach (var s in Services.Values)
{
foreach (var b in s.Description.Bindings)
{
SetBinding(s.Description.Name.ToUpper(), b);
}
}
}
private static bool TryGetLaunchSettings(string projectFilePath, out JsonElement projectSettings)
{
var projectDirectory = Path.GetDirectoryName(projectFilePath);
var launchSettingsPath = Path.Combine(projectDirectory, "Properties", "launchSettings.json");
if (!File.Exists(launchSettingsPath))
{
projectSettings = default;
return false;
}
// If there's a launchSettings.json, then use it to get addresses
var root = JsonSerializer.Deserialize<JsonElement>(File.ReadAllText(launchSettingsPath));
var key = Path.GetFileNameWithoutExtension(projectFilePath);
var profiles = root.GetProperty("profiles");
return profiles.TryGetProperty(key, out projectSettings);
}
}
}

Просмотреть файл

@ -0,0 +1,169 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reactive.Subjects;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Micronetes.Hosting.Model
{
public class Service
{
public Service()
{
Logs.Subscribe(entry =>
{
if (CachedLogs.Count > 5000)
{
CachedLogs.Dequeue();
}
CachedLogs.Enqueue(entry);
});
}
public ServiceDescription Description { get; set; }
public int Restarts { get; set; }
public ServiceType ServiceType
{
get
{
if (Description.DockerImage != null)
{
return ServiceType.Container;
}
if (Description.Project != null)
{
return ServiceType.Project;
}
return ServiceType.Executable;
}
}
public ServiceStatus Status { get; set; } = new ServiceStatus();
public ConcurrentDictionary<string, ReplicaStatus> Replicas { get; set; } = new ConcurrentDictionary<string, ReplicaStatus>();
[JsonIgnore]
public Dictionary<int, List<int>> PortMap { get; set; } = new Dictionary<int, List<int>>();
[JsonIgnore]
public Dictionary<object, object> Items { get; } = new Dictionary<object, object>();
[JsonIgnore]
public Queue<string> CachedLogs { get; } = new Queue<string>();
[JsonIgnore]
public Subject<string> Logs { get; } = new Subject<string>();
[JsonIgnore]
public Subject<ReplicaEvent> ReplicaEvents { get; } = new Subject<ReplicaEvent>();
}
public readonly struct ReplicaEvent
{
public ReplicaState State { get; }
public ReplicaStatus Replica { get; }
public ReplicaEvent(ReplicaState state, ReplicaStatus replica)
{
State = state;
Replica = replica;
}
}
public enum ReplicaState
{
Removed,
Added,
Started,
Stopped,
}
public class ServiceStatus
{
public string ProjectFilePath { get; set; }
public string ExecutablePath { get; set; }
public string Args { get; set; }
public string WorkingDirectory { get; set; }
}
public class ProcessStatus : ReplicaStatus
{
public ProcessStatus(Service service, string name) : base(service, name)
{
}
public int? ExitCode { get; set; }
public int? Pid { get; set; }
public IDictionary<string, string> Environment { get; set; }
}
public class DockerStatus : ReplicaStatus
{
public DockerStatus(Service service, string name) : base(service, name)
{
}
public string DockerCommand { get; set; }
public string ContainerId { get; set; }
public int DockerLogsPid { get; set; }
}
public class ReplicaStatus
{
public ReplicaStatus(Service service, string name)
{
Service = service;
Name = name;
}
public string Name { get; }
public static JsonConverter<ReplicaStatus> JsonConverter = new Converter();
public IEnumerable<int> Ports { get; set; }
[JsonIgnore]
public Service Service { get; }
[JsonIgnore]
public Dictionary<object, object> Items { get; } = new Dictionary<object, object>();
[JsonIgnore]
public Dictionary<string, string> Metrics { get; set; } = new Dictionary<string, string>();
private class Converter : JsonConverter<ReplicaStatus>
{
public override ReplicaStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, ReplicaStatus value, JsonSerializerOptions options)
{
// Use the runtime type since we really want to serialize either the DockerStatus or ProcessStatus
JsonSerializer.Serialize(writer, value, value.GetType(), options);
}
}
}
public enum ServiceType
{
Project,
Executable,
Container
}
public class PortMapping
{
public int ExternalPort { get; set; }
public List<int> InteralPorts { get; set; } = new List<int>();
}
}

Просмотреть файл

@ -0,0 +1,12 @@
namespace Micronetes.Hosting.Model
{
public class ServiceBinding
{
public string Name { get; set; }
public string ConnectionString { get; set; }
public int? Port { get; set; }
public int? InternalPort { get; set; }
public string Host { get; set; }
public string Protocol { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Linq;
using YamlDotNet.Serialization;
namespace Micronetes.Hosting.Model
{
public class ServiceDescription
{
public string Name { get; set; }
public bool External { get; set; }
public string DockerImage { get; set; }
public string Project { get; set; }
public bool? Build { get; set; } = true;
public string Executable { get; set; }
public string WorkingDirectory { get; set; }
public string Args { get; set; }
public int? Replicas { get; set; }
public List<ServiceBinding> Bindings { get; set; } = new List<ServiceBinding>();
[YamlMember(Alias = "env")]
public List<ConfigurationSource> Configuration { get; set; } = new List<ConfigurationSource>();
}
public class ConfigurationSource
{
public string Name { get; set; }
public string Value { get; set; }
public string Source { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Micronetes.Hosting.Model
{
public enum ServiceState
{
Starting,
Running,
NotRunning,
Stopped
}
}

Просмотреть файл

@ -0,0 +1,300 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Micronetes.Hosting.Model;
using Microsoft.Extensions.Logging;
namespace Micronetes.Hosting
{
public class ProcessRunner : IApplicationProcessor
{
private readonly ILogger _logger;
private readonly bool _debugMode;
private readonly bool _buildProjects;
public ProcessRunner(ILogger logger, ProcessRunnerOptions options)
{
_logger = logger;
_debugMode = options.DebugMode;
_buildProjects = options.BuildProjects;
}
public Task StartAsync(Application application)
{
var tasks = new Task[application.Services.Count];
var index = 0;
foreach (var s in application.Services)
{
tasks[index++] = s.Value.Description.External ? Task.CompletedTask : LaunchService(application, s.Value);
}
return Task.WhenAll(tasks);
}
public Task StopAsync(Application application)
{
return KillRunningProcesses(application.Services);
}
private async Task LaunchService(Application application, Service service)
{
var serviceDescription = service.Description;
if (serviceDescription.DockerImage != null)
{
return;
}
var serviceName = serviceDescription.Name;
var path = "";
var workingDirectory = "";
var args = service.Description.Args ?? "";
if (serviceDescription.Project != null)
{
var expandedProject = Environment.ExpandEnvironmentVariables(serviceDescription.Project);
var fullProjectPath = Path.GetFullPath(Path.Combine(application.ContextDirectory, expandedProject));
path = GetExePath(fullProjectPath);
workingDirectory = Path.GetDirectoryName(fullProjectPath);
service.Status.ProjectFilePath = fullProjectPath;
}
else
{
var expandedExecutable = Environment.ExpandEnvironmentVariables(serviceDescription.Executable);
path = Path.GetFullPath(Path.Combine(application.ContextDirectory, expandedExecutable));
workingDirectory = serviceDescription.WorkingDirectory != null ?
Path.GetFullPath(Path.Combine(application.ContextDirectory, Environment.ExpandEnvironmentVariables(serviceDescription.WorkingDirectory))) :
Path.GetDirectoryName(path);
}
// If this is a dll then use dotnet to run it
if (Path.GetExtension(path) == ".dll")
{
args = $"\"{path}\" {args}".Trim();
path = "dotnet";
}
service.Status.ExecutablePath = path;
service.Status.WorkingDirectory = workingDirectory;
service.Status.Args = args;
var processInfo = new ProcessInfo
{
Tasks = new Task[service.Description.Replicas.Value]
};
if (service.Status.ProjectFilePath != null && service.Description.Build.GetValueOrDefault() && _buildProjects)
{
// Sometimes building can fail because of file locking (like files being open in VS)
_logger.LogInformation("Building project {ProjectFile}", service.Status.ProjectFilePath);
service.Logs.OnNext($"dotnet build \"{service.Status.ProjectFilePath}\" /nologo");
var buildResult = await ProcessUtil.RunAsync("dotnet", $"build \"{service.Status.ProjectFilePath}\" /nologo",
outputDataReceived: data => service.Logs.OnNext(data),
throwOnError: false);
if (buildResult.ExitCode != 0)
{
_logger.LogInformation("Building {ProjectFile} failed with exit code {ExitCode}: " + buildResult.StandardOutput + buildResult.StandardError, service.Status.ProjectFilePath, buildResult.ExitCode);
return;
}
}
async Task RunApplicationAsync(IEnumerable<(int Port, int BindingPort, string Protocol)> ports)
{
var hasPorts = ports.Any();
var environment = new Dictionary<string, string>
{
// Default to development environment
["DOTNET_ENVIRONMENT"] = "Development"
};
application.PopulateEnvironment(service, (k, v) => environment[k] = v);
if (_debugMode)
{
environment["DOTNET_STARTUP_HOOKS"] = typeof(Hosting.Runtime.HostingRuntimeHelpers).Assembly.Location;
}
if (hasPorts)
{
// These ports should also be passed in not assuming ASP.NET Core
environment["ASPNETCORE_URLS"] = string.Join(";", ports.Select(p => $"{p.Protocol ?? "http"}://localhost:{p.Port}"));
foreach (var p in ports)
{
environment[$"{p.Protocol?.ToUpper() ?? "HTTP"}_PORT"] = p.BindingPort.ToString();
}
}
while (!processInfo.StoppedTokenSource.IsCancellationRequested)
{
var replica = serviceName + "_" + Guid.NewGuid().ToString().Substring(0, 10).ToLower();
var status = new ProcessStatus(service, replica);
service.Replicas[replica] = status;
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Added, status));
// This isn't your host name
environment["APP_INSTANCE"] = replica;
status.ExitCode = null;
status.Pid = null;
status.Environment = environment;
if (hasPorts)
{
status.Ports = ports.Select(p => p.Port);
}
_logger.LogInformation("Launching service {ServiceName}: {ExePath} {args}", replica, path, args);
try
{
service.Logs.OnNext($"[{replica}]:{path} {args}");
var result = await ProcessUtil.RunAsync(path, args,
environmentVariables: environment,
workingDirectory: workingDirectory,
outputDataReceived: data => service.Logs.OnNext($"[{replica}]: {data}"),
onStart: pid =>
{
if (hasPorts)
{
_logger.LogInformation("{ServiceName} running on process id {PID} bound to {Address}", replica, pid, string.Join(", ", ports.Select(p => $"{p.Protocol ?? "http"}://localhost:{p.Port}")));
}
else
{
_logger.LogInformation("{ServiceName} running on process id {PID}", replica, pid);
}
status.Pid = pid;
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Started, status));
},
throwOnError: false,
cancellationToken: processInfo.StoppedTokenSource.Token);
status.ExitCode = result.ExitCode;
if (status.Pid != null)
{
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Stopped, status));
}
}
catch (Exception ex)
{
_logger.LogError(0, ex, "Failed to launch process for service {ServiceName}", replica);
Thread.Sleep(5000);
}
service.Restarts++;
if (status.ExitCode != null)
{
_logger.LogInformation("{ServiceName} process exited with exit code {ExitCode}", replica, status.ExitCode);
}
// Remove the replica from the set
service.Replicas.TryRemove(replica, out _);
service.ReplicaEvents.OnNext(new ReplicaEvent(ReplicaState.Removed, status));
}
}
if (serviceDescription.Bindings.Count > 0)
{
// Each replica is assigned a list of internal ports, one mapped to each external
// port
for (int i = 0; i < serviceDescription.Replicas; i++)
{
var ports = new List<(int, int, string)>();
foreach (var binding in serviceDescription.Bindings)
{
if (binding.Port == null)
{
continue;
}
ports.Add((service.PortMap[binding.Port.Value][i], binding.Port.Value, binding.Protocol));
}
processInfo.Tasks[i] = RunApplicationAsync(ports);
}
}
else
{
for (int i = 0; i < service.Description.Replicas; i++)
{
processInfo.Tasks[i] = RunApplicationAsync(Enumerable.Empty<(int, int, string)>());
}
}
service.Items[typeof(ProcessInfo)] = processInfo;
}
private Task KillRunningProcesses(IDictionary<string, Service> services)
{
static async Task KillProcessAsync(Service service)
{
if (service.Items.TryGetValue(typeof(ProcessInfo), out var stateObj) && stateObj is ProcessInfo state)
{
// Cancel the token before stopping the process
state.StoppedTokenSource.Cancel();
await Task.WhenAll(state.Tasks);
}
}
var index = 0;
var tasks = new Task[services.Count];
foreach (var s in services.Values)
{
var state = s;
tasks[index++] = KillProcessAsync(state);
}
return Task.WhenAll(tasks);
}
private static string GetExePath(string projectFilePath)
{
// TODO: Use msbuild to get the target path
var outputFileName = Path.GetFileNameWithoutExtension(projectFilePath) + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "");
var debugOutputPath = Path.Combine(Path.GetDirectoryName(projectFilePath), "bin", "Debug");
var tfms = Directory.Exists(debugOutputPath) ? Directory.GetDirectories(debugOutputPath) : Array.Empty<string>();
if (tfms.Length > 0)
{
// Pick the first one
var path = Path.Combine(debugOutputPath, tfms[0], outputFileName);
if (File.Exists(path))
{
return path;
}
// Older versions of .NET Core didn't have TFMs
return Path.Combine(debugOutputPath, tfms[0], Path.GetFileNameWithoutExtension(projectFilePath) + ".dll");
}
return Path.Combine(debugOutputPath, "netcoreapp3.1", outputFileName);
}
private class ProcessInfo
{
public Task[] Tasks { get; set; }
public CancellationTokenSource StoppedTokenSource { get; set; } = new CancellationTokenSource();
}
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Micronetes.Hosting
{
public class ProcessRunnerOptions
{
public bool DebugMode { get; set; }
public bool BuildProjects { get; set; }
public static ProcessRunnerOptions FromArgs(string[] args)
{
return new ProcessRunnerOptions
{
BuildProjects = !args.Contains("--no-build"),
DebugMode = args.Contains("--debug")
};
}
}
}

Просмотреть файл

@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using Bedrock.Framework;
using Micronetes.Hosting.Model;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Micronetes.Hosting
{
public class ProxyService : IApplicationProcessor
{
private IHost _host;
private readonly ILogger _logger;
public ProxyService(ILogger logger)
{
_logger = logger;
}
public async Task StartAsync(Application application)
{
_host = new HostBuilder()
.ConfigureServer(server =>
{
server.UseSockets(sockets =>
{
foreach (var service in application.Services.Values)
{
if (service.Description.External)
{
// We eventually want to proxy everything, this is temporary
continue;
}
static int GetNextPort()
{
// Let the OS assign the next available port. Unless we cycle through all ports
// on a test run, the OS will always increment the port number when making these calls.
// This prevents races in parallel test runs where a test is already bound to
// a given port, and a new test is able to bind to the same port due to port
// reuse being enabled by default by the OS.
using var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
return ((IPEndPoint)socket.LocalEndPoint).Port;
}
foreach (var binding in service.Description.Bindings)
{
if (binding.Port == null)
{
continue;
}
if (service.Description.Replicas == 1)
{
// No need to proxy
service.PortMap[binding.Port.Value] = new List<int> { binding.Port.Value };
continue;
}
var ports = new List<int>();
for (int i = 0; i < service.Description.Replicas; i++)
{
// Reserve a port for each replica
var port = GetNextPort();
ports.Add(port);
}
_logger.LogInformation("Mapping external port {ExternalPort} to internal port(s) {InternalPorts} for {ServiceName}", binding.Port, string.Join(", ", ports.Select(p => p.ToString())), service.Description.Name);
service.PortMap[binding.Port.Value] = ports;
sockets.Listen(IPAddress.Loopback, binding.Port.Value, o =>
{
long count = 0;
// o.UseConnectionLogging("Micronetes.Proxy");
o.Run(async connection =>
{
var notificationFeature = connection.Features.Get<IConnectionLifetimeNotificationFeature>();
var next = (int)(Interlocked.Increment(ref count) % ports.Count);
NetworkStream targetStream = null;
try
{
var target = new Socket(SocketType.Stream, ProtocolType.Tcp)
{
NoDelay = true
};
var port = ports[next];
_logger.LogDebug("Attempting to connect to {ServiceName} listening on {ExternalPort}:{Port}", service.Description.Name, binding.Port, port);
await target.ConnectAsync(IPAddress.Loopback, port);
_logger.LogDebug("Successfully connected to {ServiceName} listening on {ExternalPort}:{Port}", service.Description.Name, binding.Port, port);
targetStream = new NetworkStream(target, ownsSocket: true);
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Proxy error for service {ServiceName}", service.Description.Name);
await targetStream.DisposeAsync();
connection.Abort();
return;
}
try
{
_logger.LogDebug("Proxying traffic to {ServiceName} {ExternalPort}:{InternalPort}", service.Description.Name, binding.Port, ports[next]);
// external -> internal
var reading = Task.Run(() => connection.Transport.Input.CopyToAsync(targetStream, notificationFeature.ConnectionClosedRequested));
// internal -> external
var writing = Task.Run(() => targetStream.CopyToAsync(connection.Transport.Output, notificationFeature.ConnectionClosedRequested));
await Task.WhenAll(reading, writing);
}
catch (ConnectionResetException)
{
// Connection was reset
}
catch (OperationCanceledException ex)
{
if (!notificationFeature.ConnectionClosedRequested.IsCancellationRequested)
{
_logger.LogDebug(0, ex, "Proxy error for service {ServiceName}", service.Description.Name);
}
}
catch (Exception ex)
{
_logger.LogDebug(0, ex, "Proxy error for service {ServiceName}", service.Description.Name);
}
finally
{
await targetStream.DisposeAsync();
}
// This needs to reconnect to the target port(s) until its bound
// it has to stop if the service is no longer running
});
});
}
}
});
})
.Build();
await _host.StartAsync();
}
public async Task StopAsync(Application application)
{
if (_host != null)
{
await _host.StopAsync();
await (_host as IAsyncDisposable).DisposeAsync();
}
}
}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,86 @@
SIL OPEN FONT LICENSE Version 1.1
Copyright (c) 2014 Waybury
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Просмотреть файл

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Waybury
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Просмотреть файл

@ -0,0 +1,114 @@
[Open Iconic v1.1.1](http://useiconic.com/open)
===========
### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint&mdash;ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
## What's in Open Iconic?
* 223 icons designed to be legible down to 8 pixels
* Super-light SVG files - 61.8 for the entire set
* SVG sprite&mdash;the modern replacement for icon fonts
* Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
* Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
* PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
## Getting Started
#### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
### General Usage
#### Using Open Iconic's SVGs
We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
```
<img src="/open-iconic/svg/icon-name.svg" alt="icon name">
```
#### Using Open Iconic's SVG Sprite
Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `<svg>` *tag and a unique class name for each different icon in the* `<use>` *tag.*
```
<svg class="icon">
<use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use>
</svg>
```
Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `<svg>` tag with equal width and height dimensions.
```
.icon {
width: 16px;
height: 16px;
}
```
Coloring icons is even easier. All you need to do is set the `fill` rule on the `<use>` tag.
```
.icon-account-login {
fill: #f00;
}
```
To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/).
#### Using Open Iconic's Icon Font...
##### …with Bootstrap
You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}`
```
<link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet">
```
```
<span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span>
```
##### …with Foundation
You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}`
```
<link href="/open-iconic/font/css/open-iconic-foundation.css" rel="stylesheet">
```
```
<span class="fi-icon-name" title="icon name" aria-hidden="true"></span>
```
##### …on its own
You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}`
```
<link href="/open-iconic/font/css/open-iconic.css" rel="stylesheet">
```
```
<span class="oi" data-glyph="icon-name" title="icon name" aria-hidden="true"></span>
```
## License
### Icons
All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT).
### Fonts
All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web).

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,543 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<!--
2014-7-1: Created.
-->
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014
By P.J. Onori
Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net)
</metadata>
<defs>
<font id="open-iconic" horiz-adv-x="800" >
<font-face
font-family="Icons"
font-weight="400"
font-stretch="normal"
units-per-em="800"
panose-1="2 0 5 3 0 0 0 0 0 0"
ascent="800"
descent="0"
bbox="-0.5 -101 802 800.126"
underline-thickness="50"
underline-position="-100"
unicode-range="U+E000-E0DE"
/>
<missing-glyph />
<glyph glyph-name="" unicode="&#xe000;"
d="M300 700h500v-700h-500v100h400v500h-400v100zM400 500l200 -150l-200 -150v100h-400v100h400v100z" />
<glyph glyph-name="1" unicode="&#xe001;"
d="M300 700h500v-700h-500v100h400v500h-400v100zM200 500v-100h400v-100h-400v-100l-200 150z" />
<glyph glyph-name="2" unicode="&#xe002;"
d="M350 700c193 0 350 -157 350 -350v-50h100l-200 -200l-200 200h100v50c0 138 -112 250 -250 250s-250 -112 -250 -250c0 193 157 350 350 350z" />
<glyph glyph-name="3" unicode="&#xe003;"
d="M450 700c193 0 350 -157 350 -350c0 138 -112 250 -250 250s-250 -112 -250 -250v-50h100l-200 -200l-200 200h100v50c0 193 157 350 350 350z" />
<glyph glyph-name="4" unicode="&#xe004;"
d="M0 700h800v-100h-800v100zM100 500h600v-100h-600v100zM0 300h800v-100h-800v100zM100 100h600v-100h-600v100z" />
<glyph glyph-name="5" unicode="&#xe005;"
d="M0 700h800v-100h-800v100zM0 500h600v-100h-600v100zM0 300h800v-100h-800v100zM0 100h600v-100h-600v100z" />
<glyph glyph-name="6" unicode="&#xe006;"
d="M0 700h800v-100h-800v100zM200 500h600v-100h-600v100zM0 300h800v-100h-800v100zM200 100h600v-100h-600v100z" />
<glyph glyph-name="7" unicode="&#xe007;"
d="M400 700c75 0 146 -23 206 -59l-75 -225l-322 234c57 31 122 50 191 50zM125 588l191 -138l-310 -222c-4 24 -6 47 -6 72c0 114 49 215 125 288zM688 575c69 -72 112 -168 112 -275c0 -35 -8 -68 -16 -100h-218zM216 253l112 -347c-128 23 -232 109 -287 222zM372 100
h372c-64 -109 -177 -185 -310 -197z" />
<glyph glyph-name="8" unicode="&#xe008;" horiz-adv-x="600"
d="M200 800h100v-500h200l-247 -300l-253 300h200v500z" />
<glyph glyph-name="9" unicode="&#xe009;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM300 700v-300h-200l300 -300l300 300h-200v300h-200z" />
<glyph glyph-name="a" unicode="&#xe00a;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM400 700l-300 -300l300 -300v200h300v200h-300v200z" />
<glyph glyph-name="b" unicode="&#xe00b;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM400 700v-200h-300v-200h300v-200l300 300z" />
<glyph glyph-name="c" unicode="&#xe00c;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM400 700l-300 -300h200v-300h200v300h200z" />
<glyph glyph-name="d" unicode="&#xe00d;"
d="M300 600v-200h500v-100h-500v-200l-300 247z" />
<glyph glyph-name="e" unicode="&#xe00e;"
d="M500 600l300 -247l-300 -253v200h-500v100h500v200z" />
<glyph glyph-name="f" unicode="&#xe00f;" horiz-adv-x="600"
d="M200 800h200v-500h200l-297 -300l-303 300h200v500z" />
<glyph glyph-name="10" unicode="&#xe010;"
d="M300 700v-200h500v-200h-500v-200l-300 297z" />
<glyph glyph-name="11" unicode="&#xe011;"
d="M500 700l300 -297l-300 -303v200h-500v200h500v200z" />
<glyph glyph-name="12" unicode="&#xe012;" horiz-adv-x="600"
d="M297 800l303 -300h-200v-500h-200v500h-200z" />
<glyph glyph-name="13" unicode="&#xe013;" horiz-adv-x="600"
d="M247 800l253 -300h-200v-500h-100v500h-200z" />
<glyph glyph-name="14" unicode="&#xe014;"
d="M400 800h100v-800h-100v800zM200 700h100v-600h-100v600zM600 600h100v-400h-100v400zM0 500h100v-200h-100v200z" />
<glyph glyph-name="15" unicode="&#xe015;"
d="M116 600l72 -72c-54 -54 -88 -126 -88 -209s34 -159 88 -213l-72 -72c-72 72 -116 175 -116 285s44 209 116 281zM684 600c72 -72 116 -171 116 -281s-44 -213 -116 -285l-72 72c54 54 88 130 88 213s-34 155 -88 209zM259 460l69 -72c-18 -18 -28 -41 -28 -69
s10 -54 28 -72l-69 -72c-36 36 -59 89 -59 144s23 105 59 141zM541 459c36 -36 59 -85 59 -140s-23 -108 -59 -144l-69 72c18 18 28 44 28 72s-10 51 -28 69z" />
<glyph glyph-name="16" unicode="&#xe016;" horiz-adv-x="400"
d="M200 800c110 0 200 -90 200 -200s-90 -200 -200 -200s-200 90 -200 200s90 200 200 200zM100 319c31 -11 65 -19 100 -19s68 8 100 19v-319l-100 100l-100 -100v319z" />
<glyph glyph-name="17" unicode="&#xe017;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700c-166 0 -300 -134 -300 -300c0 -66 21 -126 56 -175l419 419c-49 35 -109 56 -175 56zM644 575l-419 -419c49 -35 109 -56 175 -56c166 0 300 134 300 300
c0 66 -21 126 -56 175z" />
<glyph glyph-name="18" unicode="&#xe018;"
d="M0 700h100v-600h700v-100h-800v700zM500 700h200v-500h-200v500zM200 500h200v-300h-200v300z" />
<glyph glyph-name="19" unicode="&#xe019;"
d="M397 800c13 1 23 -4 34 -13c2 -2 214 -254 241 -287h128v-100h-100v-366c0 -18 -16 -34 -34 -34h-532c-18 0 -34 16 -34 34v366h-100v100h128l234 281c9 11 22 18 35 19zM400 672l-144 -172h288zM250 300c-28 0 -50 -22 -50 -50v-100c0 -28 22 -50 50 -50s50 22 50 50
v100c0 28 -22 50 -50 50zM550 300c-28 0 -50 -22 -50 -50v-100c0 -28 22 -50 50 -50s50 22 50 50v100c0 28 -22 50 -50 50z" />
<glyph glyph-name="1a" unicode="&#xe01a;"
d="M9 700h682c6 0 9 -4 9 -10v-190h100v-200h-100v-191c0 -6 -3 -9 -9 -9h-682c-6 0 -9 3 -9 9v582c0 6 3 9 9 9zM100 600v-400h500v400h-500z" />
<glyph glyph-name="1b" unicode="&#xe01b;"
d="M9 700h682c6 0 9 -4 9 -10v-190h100v-200h-100v-191c0 -6 -3 -9 -9 -9h-682c-6 0 -9 3 -9 9v582c0 6 3 9 9 9z" />
<glyph glyph-name="1c" unicode="&#xe01c;"
d="M92 650c0 23 19 50 45 50h3h5h5h500c28 0 50 -22 50 -50s-22 -50 -50 -50h-50v-141c9 -17 120 -231 166 -309c16 -26 34 -61 34 -106c0 -39 -15 -77 -41 -103h-3c-26 -25 -62 -41 -100 -41h-512c-39 0 -77 15 -103 41s-41 64 -41 103c0 46 18 80 34 106
c46 78 157 292 166 309v141h-50c-2 0 -6 -1 -8 -1c-28 0 -50 23 -50 51zM500 600h-200v-162l-6 -10s-63 -123 -119 -228h450c-56 105 -119 228 -119 228l-6 10v162z" />
<glyph glyph-name="1d" unicode="&#xe01d;"
d="M400 800c110 0 200 -90 200 -200c0 -104 52 -198 134 -266c41 -34 66 -82 66 -134h-800c0 52 25 100 66 134c82 68 134 162 134 266c0 110 90 200 200 200zM300 100h200c0 -55 -45 -100 -100 -100s-100 45 -100 100z" />
<glyph glyph-name="1e" unicode="&#xe01e;" horiz-adv-x="600"
d="M150 800h50l350 -250l-225 -147l225 -153l-350 -250h-50v250l-75 -75l-75 75l150 150l-150 150l75 75l75 -75v250zM250 650v-200l150 100zM250 350v-200l150 100z" />
<glyph glyph-name="1f" unicode="&#xe01f;"
d="M0 800h500c110 0 200 -90 200 -200c0 -47 -17 -91 -44 -125c85 -40 144 -125 144 -225c0 -138 -112 -250 -250 -250h-550v100c55 0 100 45 100 100v400c0 55 -45 100 -100 100v100zM300 700v-200h100c55 0 100 45 100 100s-45 100 -100 100h-100zM300 400v-300h150
c83 0 150 67 150 150s-67 150 -150 150h-150z" />
<glyph glyph-name="20" unicode="&#xe020;" horiz-adv-x="600"
d="M300 800v-300h200l-300 -500v300h-200z" />
<glyph glyph-name="21" unicode="&#xe021;"
d="M100 800h300v-300l100 100l100 -100v300h50c28 0 50 -22 50 -50v-550h-550c-28 0 -50 -22 -50 -50s22 -50 50 -50h550v-100h-550c-83 0 -150 67 -150 150v550l3 19c8 39 39 70 78 78z" />
<glyph glyph-name="22" unicode="&#xe022;" horiz-adv-x="400"
d="M0 800h400v-800l-200 200l-200 -200v800z" />
<glyph glyph-name="23" unicode="&#xe023;"
d="M0 800h800v-100h-800v100zM0 600h300v-103h203v103h297v-591c0 -6 -3 -9 -9 -9h-782c-6 0 -9 3 -9 9v591z" />
<glyph glyph-name="24" unicode="&#xe024;"
d="M300 800h200c55 0 100 -45 100 -100v-100h191c6 0 9 -3 9 -9v-241c0 -28 -22 -50 -50 -50h-700c-28 0 -50 22 -50 50v241c0 6 3 9 9 9h191v100c0 55 45 100 100 100zM300 700v-100h200v100h-200zM0 209c16 -6 32 -9 50 -9h700c18 0 34 3 50 9v-200c0 -6 -3 -9 -9 -9h-782
c-6 0 -9 3 -9 9v200z" />
<glyph glyph-name="25" unicode="&#xe025;" horiz-adv-x="600"
d="M300 800c58 0 110 -16 147 -53s53 -89 53 -147h-100c0 39 -11 61 -25 75s-36 25 -75 25c-35 0 -55 -10 -72 -31s-28 -55 -28 -94c0 -51 20 -107 28 -175h172v-100h-178c-14 -60 -49 -127 -113 -200h491v-100h-600v122l16 12c69 69 95 121 106 166h-122v100h125
c-8 50 -25 106 -25 175c0 58 16 114 50 156c34 43 88 69 150 69z" />
<glyph glyph-name="26" unicode="&#xe026;"
d="M34 700h4h3h4h5h700c28 0 50 -22 50 -50v-700c0 -28 -22 -50 -50 -50h-700c-28 0 -50 22 -50 50v700v2c0 20 15 42 34 48zM150 600c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50zM350 600c-28 0 -50 -22 -50 -50s22 -50 50 -50h300c28 0 50 22 50 50
s-22 50 -50 50h-300zM100 400v-400h600v400h-600z" />
<glyph glyph-name="27" unicode="&#xe027;"
d="M744 797l6 -3l44 -44c4 -4 3 -8 0 -12l-266 -375l-15 -13l-25 -12c-23 72 -78 127 -150 150l12 25l13 15l375 266zM266 400c74 0 134 -60 134 -134c0 -147 -119 -266 -266 -266c-48 0 -95 12 -134 34c80 46 134 133 134 232c0 74 58 134 132 134z" />
<glyph glyph-name="28" unicode="&#xe028;"
d="M9 451c0 23 19 50 46 50c8 0 19 -3 26 -7l131 -66l29 22c-79 81 -1 250 118 250s197 -167 119 -250l28 -22l131 66c6 4 12 7 21 7c28 0 50 -22 50 -50c0 -17 -12 -37 -27 -45l-115 -56c9 -16 19 -33 25 -50h68c28 0 50 -22 50 -50s-22 -50 -50 -50h-50
c0 -23 -2 -45 -6 -66l78 -40c21 -5 37 -28 37 -49c0 -28 -22 -50 -50 -50c-10 0 -23 5 -31 11l-65 35c-24 -46 -62 -86 -103 -110c-35 19 -60 45 -60 72v135v4v5v6v5v5v87c0 28 -22 50 -50 50c-24 0 -45 -17 -50 -40c1 -3 1 -8 1 -11s0 -8 -1 -11v-82v-4v-5v-144
c0 -28 -24 -53 -59 -72c-41 25 -79 64 -103 110l-66 -35c-8 -6 -21 -11 -31 -11c-28 0 -50 22 -50 50c0 21 16 44 37 49l78 40c-4 21 -6 43 -6 66h-50h-5c-28 0 -50 22 -50 50c0 26 22 50 50 50h5h69c6 17 16 34 25 50l-116 56c-16 7 -28 27 -28 45z" />
<glyph glyph-name="29" unicode="&#xe029;"
d="M600 700h91c6 0 9 -3 9 -9v-582c0 -6 -3 -9 -9 -9h-91v600zM210 503l290 147v-500l-250 125v-3c-15 0 -25 -8 -28 -22l75 -178c11 -25 0 -58 -25 -69s-58 0 -69 25l-103 272h-91c-6 0 -9 3 -9 9v182c0 6 3 9 9 9h182z" />
<glyph glyph-name="2a" unicode="&#xe02a;"
d="M9 800h682c6 0 9 -3 9 -9v-782c0 -6 -3 -9 -9 -9h-682c-6 0 -9 3 -9 9v782c0 6 3 9 9 9zM100 700v-200h500v200h-500zM100 400v-100h100v100h-100zM300 400v-100h100v100h-100zM500 400v-300h100v300h-100zM100 200v-100h100v100h-100zM300 200v-100h100v100h-100z" />
<glyph glyph-name="2b" unicode="&#xe02b;"
d="M0 800h700v-200h-700v200zM0 500h700v-491c0 -6 -3 -9 -9 -9h-682c-6 0 -9 3 -9 9v491zM100 400v-100h100v100h-100zM300 400v-100h100v100h-100zM500 400v-100h100v100h-100zM100 200v-100h100v100h-100zM300 200v-100h100v100h-100z" />
<glyph glyph-name="2c" unicode="&#xe02c;"
d="M409 800h182c6 0 10 -4 12 -9l94 -182c2 -5 6 -9 12 -9h82c6 0 9 -3 9 -9v-582c0 -6 -3 -9 -9 -9h-782c-6 0 -9 3 -9 9v441c0 83 67 150 150 150h141c6 0 10 4 12 9l94 182c2 5 6 9 12 9zM150 500c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50z
M500 500c-110 0 -200 -90 -200 -200s90 -200 200 -200s200 90 200 200s-90 200 -200 200zM500 400c55 0 100 -45 100 -100s-45 -100 -100 -100s-100 45 -100 100s45 100 100 100z" />
<glyph glyph-name="2d" unicode="&#xe02d;"
d="M0 600h800l-400 -400z" />
<glyph glyph-name="2e" unicode="&#xe02e;" horiz-adv-x="400"
d="M400 800v-800l-400 400z" />
<glyph glyph-name="2f" unicode="&#xe02f;" horiz-adv-x="400"
d="M0 800l400 -400l-400 -400v800z" />
<glyph glyph-name="30" unicode="&#xe030;"
d="M400 600l400 -400h-800z" />
<glyph glyph-name="31" unicode="&#xe031;"
d="M0 550c0 23 20 50 46 50h3h5h4h200c17 0 37 -13 44 -28l38 -72h444c14 0 19 -12 15 -25l-81 -250c-4 -13 -21 -25 -35 -25h-350c-14 0 -30 12 -34 25c-27 83 -54 167 -81 250l-10 25h-150c-2 0 -5 -1 -7 -1c-28 0 -51 23 -51 51zM358 100c28 0 50 -22 50 -50
s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM658 100c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50z" />
<glyph glyph-name="32" unicode="&#xe032;"
d="M0 700h500v-100h-300v-300h-100l-100 -100v500zM300 500h500v-500l-100 100h-400v400z" />
<glyph glyph-name="33" unicode="&#xe033;"
d="M641 700l143 -141l-493 -493c-71 76 -146 148 -219 222l-72 71l141 141c50 -51 101 -101 153 -150c116 117 234 231 347 350z" />
<glyph glyph-name="34" unicode="&#xe034;"
d="M150 600l250 -250l250 250l150 -150l-400 -400l-400 400z" />
<glyph glyph-name="35" unicode="&#xe035;" horiz-adv-x="600"
d="M400 800l150 -150l-250 -250l250 -250l-150 -150l-400 400z" />
<glyph glyph-name="36" unicode="&#xe036;" horiz-adv-x="600"
d="M150 800l400 -400l-400 -400l-150 150l250 250l-250 250z" />
<glyph glyph-name="37" unicode="&#xe037;"
d="M400 600l400 -400l-150 -150l-250 250l-250 -250l-150 150z" />
<glyph glyph-name="38" unicode="&#xe038;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM600 622l-250 -250l-100 100l-72 -72l172 -172l322 322z" />
<glyph glyph-name="39" unicode="&#xe039;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM250 622l-72 -72l150 -150l-150 -150l72 -72l150 150l150 -150l72 72l-150 150l150 150l-72 72l-150 -150z" />
<glyph glyph-name="3a" unicode="&#xe03a;"
d="M350 800c28 0 50 -22 50 -50v-50h75c14 0 25 -11 25 -25v-75h-300v75c0 14 11 25 25 25h75v50c0 28 22 50 50 50zM25 700h75v-200h500v200h75c14 0 25 -11 25 -25v-650c0 -14 -11 -25 -25 -25h-650c-14 0 -25 11 -25 25v650c0 14 11 25 25 25z" />
<glyph glyph-name="3b" unicode="&#xe03b;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700c-166 0 -300 -134 -300 -300s134 -300 300 -300s300 134 300 300s-134 300 -300 300zM350 600h100v-181c23 -24 47 -47 72 -69l-72 -72c-27 30 -55 59 -84 88l-16 12
v222z" />
<glyph glyph-name="3c" unicode="&#xe03c;"
d="M450 800c138 0 250 -112 250 -250v-50c58 -21 100 -85 100 -150c0 -18 -3 -34 -9 -50h-191v50c0 83 -67 150 -150 150s-150 -67 -150 -150v-50h-272c-17 30 -28 63 -28 100c0 110 90 200 200 200c23 114 129 200 250 200zM434 400h3h4c3 0 6 1 9 1c28 0 50 -22 50 -50v-1
v-150h150l-200 -200l-200 200h150v150v2c0 20 15 42 34 48z" />
<glyph glyph-name="3d" unicode="&#xe03d;"
d="M450 800c138 0 250 -112 250 -250v-50c58 -21 100 -85 100 -150c0 -18 -3 -34 -9 -50h-141l-200 200l-200 -200h-222c-17 30 -28 63 -28 100c0 110 90 200 200 200c23 114 129 200 250 200zM450 350l250 -250h-200v-50c0 -28 -22 -50 -50 -50s-50 22 -50 50v50h-200z" />
<glyph glyph-name="3e" unicode="&#xe03e;"
d="M450 700c138 0 250 -112 250 -250v-50c58 -21 100 -85 100 -150c0 -83 -67 -150 -150 -150h-450c-110 0 -200 90 -200 200s90 200 200 200c23 114 129 200 250 200z" />
<glyph glyph-name="3f" unicode="&#xe03f;"
d="M250 800c82 0 154 -40 200 -100c-143 0 -270 -85 -325 -209c-36 -10 -70 -25 -100 -47c-16 33 -25 67 -25 106c0 138 112 250 250 250zM450 600c138 0 250 -112 250 -250v-50c58 -21 100 -85 100 -150c0 -83 -67 -150 -150 -150h-450c-110 0 -200 90 -200 200
s90 200 200 200c23 114 129 200 250 200z" />
<glyph glyph-name="40" unicode="&#xe040;"
d="M500 700h100l-300 -600h-100zM100 600h100l-100 -200l100 -200h-100l-100 200zM600 600h100l100 -200l-100 -200h-100l100 200z" />
<glyph glyph-name="41" unicode="&#xe041;"
d="M350 800h100l50 -119l28 -12l119 50l72 -72l-50 -119l12 -28l119 -50v-100l-119 -50l-12 -28l50 -119l-72 -72l-119 50l-28 -12l-50 -119h-100l-50 119l-28 12l-119 -50l-72 72l50 119l-12 28l-119 50v100l119 50l12 28l-50 119l72 72l119 -50l28 12zM400 550
c-83 0 -150 -67 -150 -150s67 -150 150 -150s150 67 150 150s-67 150 -150 150z" />
<glyph glyph-name="42" unicode="&#xe042;"
d="M0 800h800v-200h-800v200zM200 500h400l-200 -200zM0 100h800v-100h-800v100z" />
<glyph glyph-name="43" unicode="&#xe043;"
d="M0 800h100v-800h-100v800zM600 800h200v-800h-200v800zM500 600v-400l-200 200z" />
<glyph glyph-name="44" unicode="&#xe044;"
d="M0 800h200v-800h-200v800zM700 800h100v-800h-100v800zM300 600l200 -200l-200 -200v400z" />
<glyph glyph-name="45" unicode="&#xe045;"
d="M0 800h800v-100h-800v100zM400 500l200 -200h-400zM0 200h800v-200h-800v200z" />
<glyph glyph-name="46" unicode="&#xe046;"
d="M150 700c83 0 150 -67 150 -150v-50h100v50c0 83 67 150 150 150s150 -67 150 -150s-67 -150 -150 -150h-50v-100h50c83 0 150 -67 150 -150s-67 -150 -150 -150s-150 67 -150 150v50h-100v-50c0 -83 -67 -150 -150 -150s-150 67 -150 150s67 150 150 150h50v100h-50
c-83 0 -150 67 -150 150s67 150 150 150zM150 600c-28 0 -50 -22 -50 -50s22 -50 50 -50h50v50c0 28 -22 50 -50 50zM550 600c-28 0 -50 -22 -50 -50v-50h50c28 0 50 22 50 50s-22 50 -50 50zM300 400v-100h100v100h-100zM150 200c-28 0 -50 -22 -50 -50s22 -50 50 -50
s50 22 50 50v50h-50zM500 200v-50c0 -28 22 -50 50 -50s50 22 50 50s-22 50 -50 50h-50z" />
<glyph glyph-name="47" unicode="&#xe047;"
d="M0 791c0 5 4 9 9 9h782c6 0 9 -4 9 -10v-790l-200 200h-591c-6 0 -9 3 -9 9v582z" />
<glyph glyph-name="48" unicode="&#xe048;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700c-166 0 -300 -134 -300 -300s134 -300 300 -300s300 134 300 300s-134 300 -300 300zM600 600l-100 -300l-300 -100l100 300zM400 450c-28 0 -50 -22 -50 -50
s22 -50 50 -50s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="49" unicode="&#xe049;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700v-600c166 0 300 134 300 300s-134 300 -300 300z" />
<glyph glyph-name="4a" unicode="&#xe04a;"
d="M0 800h800v-100h-800v100zM0 600h500v-100h-500v100zM0 300h800v-100h-800v100zM0 100h600v-100h-600v100zM750 100c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50z" />
<glyph glyph-name="4b" unicode="&#xe04b;"
d="M25 700h750c14 0 25 -11 25 -25v-75h-800v75c0 14 11 25 25 25zM0 500h800v-375c0 -14 -11 -25 -25 -25h-750c-14 0 -25 11 -25 25v375zM100 300v-100h100v100h-100zM300 300v-100h100v100h-100z" />
<glyph glyph-name="4c" unicode="&#xe04c;"
d="M100 800h100v-100h450l100 100l50 -50l-100 -100v-450h100v-100h-100v-100h-100v100h-500v500h-100v100h100v100zM200 600v-350l350 350h-350zM600 550l-350 -350h350v350z" />
<glyph glyph-name="4d" unicode="&#xe04d;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700c-166 0 -300 -134 -300 -300s134 -300 300 -300s300 134 300 300s-134 300 -300 300zM400 600c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50z
M200 452c0 20 15 42 34 48h3h3h8c12 0 28 -7 36 -16l91 -90l25 6c55 0 100 -45 100 -100s-45 -100 -100 -100s-100 45 -100 100l6 25l-90 91c-9 8 -16 24 -16 36zM550 500c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50z" />
<glyph glyph-name="4e" unicode="&#xe04e;"
d="M300 800h200v-300h200l-300 -300l-300 300h200v300zM0 100h800v-100h-800v100z" />
<glyph glyph-name="4f" unicode="&#xe04f;"
d="M0 800h800v-100h-800v100zM400 600l300 -300h-200v-300h-200v300h-200z" />
<glyph glyph-name="50" unicode="&#xe050;"
d="M200 700h600v-600h-600l-200 300zM350 622l-72 -72l150 -150l-150 -150l72 -72l150 150l150 -150l72 72l-150 150l150 150l-72 72l-150 -150z" />
<glyph glyph-name="51" unicode="&#xe051;"
d="M400 700c220 0 400 -180 400 -400h-100c0 166 -134 300 -300 300s-300 -134 -300 -300h-100c0 220 180 400 400 400zM341 491l59 -88l59 88c81 -25 141 -101 141 -191c0 -110 -90 -200 -200 -200s-200 90 -200 200c0 90 60 166 141 191z" />
<glyph glyph-name="52" unicode="&#xe052;"
d="M0 800h300v-400h400v-400h-700v800zM400 800l300 -300h-300v300zM100 600v-100h100v100h-100zM100 400v-100h100v100h-100zM100 200v-100h400v100h-400z" />
<glyph glyph-name="53" unicode="&#xe053;" horiz-adv-x="600"
d="M200 700h100v-100h75c30 0 58 -6 81 -22s44 -44 44 -78v-100h-100v94c-4 3 -13 6 -25 6h-250c-14 0 -25 -11 -25 -25v-50c0 -15 20 -40 34 -44l257 -65c66 -16 109 -73 109 -141v-50c0 -68 -57 -125 -125 -125h-75v-100h-100v100h-75c-30 0 -58 6 -81 22s-44 44 -44 78
v100h100v-94c4 -3 13 -6 25 -6h250c14 0 25 11 25 25v50c0 15 -20 40 -34 44l-257 65c-66 16 -109 73 -109 141v50c0 68 57 125 125 125h75v100z" />
<glyph glyph-name="54" unicode="&#xe054;"
d="M0 700h300v-300l-300 -300v600zM500 700h300v-300l-300 -300v600z" />
<glyph glyph-name="55" unicode="&#xe055;"
d="M300 700v-600h-300v300zM800 700v-600h-300v300z" />
<glyph glyph-name="56" unicode="&#xe056;"
d="M300 700v-100c-111 0 -200 -89 -200 -200h200v-300h-300v300c0 165 135 300 300 300zM800 700v-100c-111 0 -200 -89 -200 -200h200v-300h-300v300c0 165 135 300 300 300z" />
<glyph glyph-name="57" unicode="&#xe057;"
d="M0 700h300v-300c0 -165 -135 -300 -300 -300v100c111 0 200 89 200 200h-200v300zM500 700h300v-300c0 -165 -135 -300 -300 -300v100c111 0 200 89 200 200h-200v300z" />
<glyph glyph-name="58" unicode="&#xe058;" horiz-adv-x="600"
d="M300 800l34 -34c11 -11 266 -270 266 -488c0 -165 -135 -300 -300 -300s-300 135 -300 300c0 218 255 477 266 488zM150 328c-28 0 -50 -22 -50 -50c0 -110 90 -200 200 -200c28 0 50 22 50 50s-22 50 -50 50c-55 0 -100 45 -100 100c0 28 -22 50 -50 50z" />
<glyph glyph-name="59" unicode="&#xe059;"
d="M400 800l400 -500h-800zM0 200h800v-200h-800v200z" />
<glyph glyph-name="5a" unicode="&#xe05a;" horiz-adv-x="600"
d="M300 800l300 -300h-600zM0 300h600l-300 -300z" />
<glyph glyph-name="5b" unicode="&#xe05b;"
d="M0 500h200v-200h-200v200zM300 500h200v-200h-200v200zM600 500h200v-200h-200v200z" />
<glyph glyph-name="5c" unicode="&#xe05c;"
d="M0 700h800v-100l-400 -200l-400 200v100zM0 500l400 -200l400 200v-400h-800v400z" />
<glyph glyph-name="5d" unicode="&#xe05d;"
d="M400 800l400 -200v-600h-800v600zM400 688l-300 -150v-188l300 -150l300 150v188zM200 500h400v-100l-200 -100l-200 100v100z" />
<glyph glyph-name="5e" unicode="&#xe05e;"
d="M600 700c69 0 134 -19 191 -50l-16 -106c-49 35 -109 56 -175 56c-131 0 -240 -84 -281 -200h331l-16 -100h-334c0 -36 8 -68 19 -100h297l-16 -100h-222c55 -61 133 -100 222 -100c78 0 147 30 200 78v-122c-59 -35 -127 -56 -200 -56c-147 0 -274 82 -344 200h-256
l19 100h197c-8 32 -16 66 -16 100h-200l25 100h191c45 172 198 300 384 300z" />
<glyph glyph-name="5f" unicode="&#xe05f;"
d="M0 700h700v-100h-700v100zM0 500h500v-100h-500v100zM0 300h800v-100h-800v100zM0 100h100v-100h-100v100zM200 100h100v-100h-100v100zM400 100h100v-100h-100v100z" />
<glyph glyph-name="60" unicode="&#xe060;"
d="M0 800h800v-100h-800v100zM200 600h400l-200 -200zM0 200h800v-200h-800v200z" />
<glyph glyph-name="61" unicode="&#xe061;"
d="M0 800h100v-800h-100v800zM600 800h200v-800h-200v800zM200 600l200 -200l-200 -200v400z" />
<glyph glyph-name="62" unicode="&#xe062;"
d="M0 800h200v-800h-200v800zM700 800h100v-800h-100v800zM600 600v-400l-200 200z" />
<glyph glyph-name="63" unicode="&#xe063;"
d="M0 800h800v-200h-800v200zM400 400l200 -200h-400zM0 100h800v-100h-800v100z" />
<glyph glyph-name="64" unicode="&#xe064;"
d="M0 800h200v-100h-100v-600h600v100h100v-200h-800v800zM400 800h400v-400l-150 150l-250 -250l-100 100l250 250z" />
<glyph glyph-name="65" unicode="&#xe065;"
d="M403 700c247 0 397 -300 397 -300s-150 -300 -397 -300c-253 0 -403 300 -403 300s150 300 403 300zM400 600c-110 0 -200 -90 -200 -200s90 -200 200 -200s200 90 200 200s-90 200 -200 200zM400 500c10 0 19 -3 28 -6c-16 -8 -28 -24 -28 -44c0 -28 22 -50 50 -50
c20 0 36 12 44 28c3 -9 6 -18 6 -28c0 -55 -45 -100 -100 -100s-100 45 -100 100s45 100 100 100z" />
<glyph glyph-name="66" unicode="&#xe066;" horiz-adv-x="900"
d="M331 700h3h3c3 1 7 1 10 1c12 0 29 -8 37 -17l94 -93l66 65c57 57 155 57 212 0c58 -58 58 -154 0 -212l-65 -66l93 -94c10 -8 18 -25 18 -38c0 -28 -22 -50 -50 -50c-13 0 -32 9 -40 20l-62 65l-381 -381h-269v272l375 381l-63 63c-9 8 -16 24 -16 36c0 20 16 42 35 48z
M447 481l-313 -315l128 -132l316 316z" />
<glyph glyph-name="67" unicode="&#xe067;"
d="M0 800h300v-400h400v-400h-700v800zM400 800l300 -300h-300v300z" />
<glyph glyph-name="68" unicode="&#xe068;"
d="M200 800c0 0 200 -100 200 -300s-298 -302 -200 -500c0 0 -200 100 -200 300s300 300 200 500zM500 500c0 0 200 -100 200 -300c0 -150 -60 -200 -100 -200h-300c0 200 300 300 200 500z" />
<glyph glyph-name="69" unicode="&#xe069;"
d="M0 800h100v-800h-100v800zM200 800h300v-100h300l-200 -203l200 -197h-400v100h-200v400z" />
<glyph glyph-name="6a" unicode="&#xe06a;" horiz-adv-x="400"
d="M150 800h150l-100 -200h200l-150 -300h150l-300 -300l-100 300h134l66 200h-200z" />
<glyph glyph-name="6b" unicode="&#xe06b;"
d="M0 800h300v-100h500v-100h-800v200zM0 500h800v-450c0 -28 -22 -50 -50 -50h-700c-28 0 -50 22 -50 50v450z" />
<glyph glyph-name="6c" unicode="&#xe06c;"
d="M150 800c83 0 150 -67 150 -150c0 -66 -41 -121 -100 -141v-118c15 5 33 9 50 9h200c28 0 50 22 50 50v59c-59 20 -100 75 -100 141c0 83 67 150 150 150s150 -67 150 -150c0 -66 -41 -121 -100 -141v-59c0 -82 -68 -150 -150 -150h-200c-14 0 -25 -7 -34 -16
c50 -24 84 -74 84 -134c0 -83 -67 -150 -150 -150s-150 67 -150 150c0 66 41 121 100 141v218c-59 20 -100 75 -100 141c0 83 67 150 150 150z" />
<glyph glyph-name="6d" unicode="&#xe06d;"
d="M0 800h400l-150 -150l150 -150l-100 -100l-150 150l-150 -150v400zM500 400l150 -150l150 150v-400h-400l150 150l-150 150z" />
<glyph glyph-name="6e" unicode="&#xe06e;"
d="M100 800l150 -150l150 150v-400h-400l150 150l-150 150zM400 400h400l-150 -150l150 -150l-100 -100l-150 150l-150 -150v400z" />
<glyph glyph-name="6f" unicode="&#xe06f;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM400 700c-56 0 -108 -17 -153 -44l22 -19c33 -18 13 -48 -13 -59c-30 -13 -77 10 -65 -41c13 -55 -27 -3 -47 -15c-42 -26 49 -152 31 -156l-59 34c-8 0 -13 -5 -16 -10
c1 -30 10 -57 19 -84c28 -11 77 -2 100 -25c47 -28 97 -115 75 -159c34 -13 68 -22 106 -22c101 0 193 48 247 125c3 24 -8 44 -50 44c-69 0 -156 13 -153 97c2 46 101 108 66 143c-30 30 12 39 12 66c0 37 -65 32 -69 50s20 36 41 56c-30 10 -60 19 -94 19zM631 591
c-38 -11 -94 -35 -87 -53c6 -15 52 -1 65 -13c11 -10 16 -59 44 -31l22 22v3c-11 26 -26 50 -44 72z" />
<glyph glyph-name="70" unicode="&#xe070;"
d="M703 800l97 -100l-400 -400l-100 100l-200 -203l-100 100l300 303l100 -100zM0 100h800v-100h-800v100z" />
<glyph glyph-name="71" unicode="&#xe071;"
d="M0 700h100v-100h-100v100zM200 700h100v-100h-100v100zM400 700h100v-100h-100v100zM600 700h100v-100h-100v100zM0 500h100v-100h-100v100zM200 500h100v-100h-100v100zM400 500h100v-100h-100v100zM600 500h100v-100h-100v100zM0 300h100v-100h-100v100zM200 300h100
v-100h-100v100zM400 300h100v-100h-100v100zM600 300h100v-100h-100v100zM0 100h100v-100h-100v100zM200 100h100v-100h-100v100zM400 100h100v-100h-100v100zM600 100h100v-100h-100v100z" />
<glyph glyph-name="72" unicode="&#xe072;"
d="M0 800h200v-200h-200v200zM300 800h200v-200h-200v200zM600 800h200v-200h-200v200zM0 500h200v-200h-200v200zM300 500h200v-200h-200v200zM600 500h200v-200h-200v200zM0 200h200v-200h-200v200zM300 200h200v-200h-200v200zM600 200h200v-200h-200v200z" />
<glyph glyph-name="73" unicode="&#xe073;"
d="M0 800h300v-300h-300v300zM500 800h300v-300h-300v300zM0 300h300v-300h-300v300zM500 300h300v-300h-300v300z" />
<glyph glyph-name="74" unicode="&#xe074;"
d="M19 800h662c11 0 19 -8 19 -19v-331c0 -28 -22 -50 -50 -50h-600c-28 0 -50 22 -50 50v331c0 11 8 19 19 19zM0 309c16 -6 32 -9 50 -9h600c18 0 34 3 50 9v-290c0 -11 -8 -19 -19 -19h-662c-11 0 -19 8 -19 19v290zM550 200c-28 0 -50 -22 -50 -50s22 -50 50 -50
s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="75" unicode="&#xe075;"
d="M0 700h300v-100h-50c-28 0 -50 -22 -50 -50v-150h300v150c0 28 -22 50 -50 50h-50v100h300v-100h-50c-28 0 -50 -22 -50 -50v-400c0 -28 22 -50 50 -50h50v-100h-300v100h50c28 0 50 22 50 50v150h-300v-150c0 -28 22 -50 50 -50h50v-100h-300v100h50c28 0 50 22 50 50
v400c0 28 -22 50 -50 50h-50v100z" />
<glyph glyph-name="76" unicode="&#xe076;"
d="M400 700c165 0 300 -135 300 -300v-100h50c28 0 50 -22 50 -50v-200c0 -28 -22 -50 -50 -50h-100c-28 0 -50 22 -50 50v350c0 111 -89 200 -200 200s-200 -89 -200 -200v-350c0 -28 -22 -50 -50 -50h-100c-28 0 -50 22 -50 50v200c0 28 22 50 50 50h50v100
c0 165 135 300 300 300z" />
<glyph glyph-name="77" unicode="&#xe077;"
d="M0 500c0 109 91 200 200 200s200 -91 200 -200c0 109 91 200 200 200s200 -91 200 -200c0 -55 -23 -105 -59 -141l-341 -340l-341 340c-36 36 -59 86 -59 141z" />
<glyph glyph-name="78" unicode="&#xe078;"
d="M400 700l400 -300l-100 3v-403h-200v200h-200v-200h-200v400h-100z" />
<glyph glyph-name="79" unicode="&#xe079;"
d="M0 800h800v-800h-800v800zM100 700v-300l100 100l400 -400h100v100l-200 200l100 100l100 -100v300h-600z" />
<glyph glyph-name="7a" unicode="&#xe07a;"
d="M19 800h762c11 0 19 -8 19 -19v-762c0 -11 -8 -19 -19 -19h-762c-11 0 -19 8 -19 19v762c0 11 8 19 19 19zM100 600v-300h100l100 -100h200l100 100h100v300h-600z" />
<glyph glyph-name="7b" unicode="&#xe07b;"
d="M200 600c80 0 142 -56 200 -122c58 66 119 122 200 122c131 0 200 -101 200 -200s-69 -200 -200 -200c-81 0 -142 56 -200 122c-58 -66 -121 -122 -200 -122c-131 0 -200 101 -200 200s69 200 200 200zM200 500c-74 0 -100 -54 -100 -100s26 -100 100 -100
c42 0 88 47 134 100c-46 53 -92 100 -134 100zM600 500c-43 0 -88 -47 -134 -100c46 -53 91 -100 134 -100c74 0 100 54 100 100s-26 100 -100 100z" />
<glyph glyph-name="7c" unicode="&#xe07c;" horiz-adv-x="400"
d="M300 800c55 0 100 -45 100 -100s-45 -100 -100 -100s-100 45 -100 100s45 100 100 100zM150 550c83 0 150 -69 150 -150c0 -66 -100 -214 -100 -250c0 -28 22 -50 50 -50s50 22 50 50h100c0 -83 -67 -150 -150 -150s-150 64 -150 150s100 222 100 250s-22 50 -50 50
s-50 -22 -50 -50h-100c0 83 67 150 150 150z" />
<glyph glyph-name="7d" unicode="&#xe07d;"
d="M200 800h500v-100h-122c-77 -197 -156 -392 -234 -588l-6 -12h162v-100h-500v100h122c77 197 156 392 234 588l7 12h-163v100z" />
<glyph glyph-name="7e" unicode="&#xe07e;"
d="M0 700h800v-100h-800v100zM0 500h800v-100h-800v100zM0 300h800v-100h-800v100zM100 100h600v-100h-600v100z" />
<glyph glyph-name="7f" unicode="&#xe07f;"
d="M0 700h800v-100h-800v100zM0 500h800v-100h-800v100zM0 300h800v-100h-800v100zM0 100h600v-100h-600v100z" />
<glyph glyph-name="80" unicode="&#xe080;"
d="M0 700h800v-100h-800v100zM0 500h800v-100h-800v100zM0 300h800v-100h-800v100zM200 100h600v-100h-600v100z" />
<glyph glyph-name="81" unicode="&#xe081;"
d="M550 800c138 0 250 -112 250 -250s-112 -250 -250 -250c-16 0 -32 0 -47 3l-3 -3v-100h-200v-200h-300v200l303 303c-3 15 -3 31 -3 47c0 138 112 250 250 250zM600 700c-55 0 -100 -45 -100 -100s45 -100 100 -100s100 45 100 100s-45 100 -100 100z" />
<glyph glyph-name="82" unicode="&#xe082;"
d="M134 600h3h4h4h5h500c28 0 50 -22 50 -50v-350h100v-150c0 -28 -22 -50 -50 -50h-700c-28 0 -50 22 -50 50v150h100v350v2c0 20 15 42 34 48zM200 500v-300h100v-100h200v100h100v300h-400z" />
<glyph glyph-name="83" unicode="&#xe083;"
d="M0 800h400v-400h-400v400zM500 600h100v-400h-400v100h300v300zM700 400h100v-400h-400v100h300v300z" />
<glyph glyph-name="84" unicode="&#xe084;" horiz-adv-x="600"
d="M337 694c6 4 12 7 21 7c28 0 50 -22 50 -50c0 -17 -12 -37 -27 -45l-300 -150c-8 -6 -21 -11 -31 -11c-28 0 -50 22 -50 50c0 21 16 44 37 49zM437 544c6 4 12 7 21 7c28 0 50 -22 50 -50c0 -17 -12 -37 -27 -45l-400 -200c-8 -6 -21 -11 -31 -11c-28 0 -50 22 -50 50
c0 21 16 44 37 49zM437 344c6 4 12 7 21 7c28 0 50 -22 50 -50c0 -17 -12 -37 -27 -45l-106 -56c24 -4 43 -26 43 -50c0 -28 -23 -51 -51 -51c-2 0 -6 1 -8 1h-200c-26 1 -48 24 -48 50c0 16 12 36 26 44zM151 -50c0 23 20 50 46 50h3h4h5h100c28 0 50 -22 50 -50
s-22 -50 -50 -50h-100c-2 0 -6 -1 -8 -1c-28 0 -50 23 -50 51z" />
<glyph glyph-name="85" unicode="&#xe085;"
d="M199 800h100v-200h-200v100h100v100zM586 797h1c18 1 38 1 56 -3c36 -8 69 -26 97 -54c78 -78 78 -203 0 -281l-150 -150c-8 -13 -28 -24 -43 -24c-28 0 -50 22 -50 50c0 15 11 35 24 43l150 150c40 40 39 105 0 144c-41 41 -110 34 -144 0l-44 -44
c-8 -13 -27 -24 -42 -24c-28 0 -50 22 -50 50c0 15 11 35 24 43l43 44c32 33 72 53 128 56zM208 490c4 5 14 16 22 16h3c2 0 6 1 8 1c28 0 50 -22 50 -50c0 -11 -6 -27 -14 -35l-150 -150c-40 -40 -39 -105 0 -144c41 -41 110 -34 144 0l44 44c8 13 27 24 42 24
c28 0 50 -22 50 -50c0 -15 -11 -35 -24 -43l-43 -44c-22 -22 -48 -37 -75 -47c-70 -25 -151 -9 -207 47c-78 78 -78 203 0 281zM499 200h200v-100h-100v-100h-100v200z" />
<glyph glyph-name="86" unicode="&#xe086;"
d="M586 797c18 1 39 1 57 -3c36 -8 69 -26 97 -54c78 -78 78 -203 0 -281l-150 -150c-62 -62 -132 -81 -182 -78s-69 17 -84 25s-26 27 -26 44c0 28 22 51 50 51c8 0 19 -3 26 -7c0 0 15 -11 41 -13s62 3 106 47l150 150c40 40 39 105 0 144c-41 41 -110 34 -144 0
c-8 -13 -28 -24 -43 -24c-28 0 -50 22 -50 50c0 15 11 35 24 43c32 33 72 53 128 56zM386 566c50 -2 64 -17 85 -22s37 -28 37 -49c0 -28 -22 -50 -50 -50c-10 0 -23 5 -31 11c0 0 -19 9 -47 10s-63 -4 -103 -44l-150 -150c-40 -40 -39 -105 0 -144c41 -41 110 -34 144 0
c8 13 27 24 42 24c28 0 50 -22 50 -50c0 -15 -10 -35 -23 -43c-22 -22 -48 -37 -75 -47c-70 -25 -151 -9 -207 47c-78 78 -78 203 0 281l150 150c60 60 128 78 178 76z" />
<glyph glyph-name="87" unicode="&#xe087;"
d="M0 700h300v-300h-300v300zM400 700h400v-100h-400v100zM400 500h300v-100h-300v100zM0 300h300v-300h-300v300zM400 300h400v-100h-400v100zM400 100h300v-100h-300v100z" />
<glyph glyph-name="88" unicode="&#xe088;"
d="M50 700c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM200 700h600v-100h-600v100zM50 500c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM200 500h600v-100h-600v100zM50 300c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50
s22 50 50 50zM200 300h600v-100h-600v100zM50 100c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM200 100h600v-100h-600v100z" />
<glyph glyph-name="89" unicode="&#xe089;"
d="M800 800l-400 -800l-100 300l-300 100z" />
<glyph glyph-name="8a" unicode="&#xe08a;" horiz-adv-x="600"
d="M300 700c110 0 200 -90 200 -200v-100h100v-400h-600v400h100v100c0 110 90 200 200 200zM300 600c-56 0 -100 -44 -100 -100v-100h200v100c0 56 -44 100 -100 100z" />
<glyph glyph-name="8b" unicode="&#xe08b;" horiz-adv-x="600"
d="M300 800c110 0 200 -90 200 -200v-200h100v-400h-600v400h400v200c0 56 -44 100 -100 100s-100 -44 -100 -100h-100c0 110 90 200 200 200z" />
<glyph glyph-name="8c" unicode="&#xe08c;"
d="M400 700v-100c-111 0 -200 -89 -200 -200h100l-150 -200l-150 200h100c0 165 135 300 300 300zM650 600l150 -200h-100c0 -165 -135 -300 -300 -300v100c111 0 200 89 200 200h-100z" />
<glyph glyph-name="8d" unicode="&#xe08d;"
d="M100 800h600v-300h100l-150 -250l-150 250h100v200h-400v-100h-100v200zM150 550l150 -250h-100v-200h400v100h100v-200h-600v300h-100z" />
<glyph glyph-name="8e" unicode="&#xe08e;"
d="M600 700l200 -150l-200 -150v100h-500v-100h-100v100c0 55 45 100 100 100h500v100zM200 300v-100h500v100h100v-100c0 -55 -45 -100 -100 -100h-500v-100l-200 150z" />
<glyph glyph-name="8f" unicode="&#xe08f;" horiz-adv-x="900"
d="M350 800c193 0 350 -157 350 -350c0 -60 -17 -117 -44 -166c5 -3 12 -8 16 -12l100 -100c16 -16 30 -49 30 -72c0 -56 -46 -102 -102 -102c-23 0 -56 14 -72 30l-100 100c-4 3 -9 9 -12 13c-49 -26 -107 -41 -166 -41c-193 0 -350 157 -350 350s157 350 350 350zM350 200
c142 0 250 108 250 250c0 139 -111 250 -250 250s-250 -111 -250 -250s111 -250 250 -250z" />
<glyph glyph-name="90" unicode="&#xe090;" horiz-adv-x="600"
d="M300 800c166 0 300 -134 300 -300c0 -200 -300 -500 -300 -500s-300 300 -300 500c0 166 134 300 300 300zM300 700c-110 0 -200 -90 -200 -200s90 -200 200 -200s200 90 200 200s-90 200 -200 200z" />
<glyph glyph-name="91" unicode="&#xe091;" horiz-adv-x="900"
d="M0 800h800v-541c1 -3 1 -8 1 -11s0 -7 -1 -10v-238h-800v800zM495 250c0 26 22 50 50 50h5h150v400h-600v-600h600v100h-150h-5c-28 0 -50 22 -50 50zM350 600c83 0 150 -67 150 -150c0 -100 -150 -250 -150 -250s-150 150 -150 250c0 83 67 150 150 150zM350 500
c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="92" unicode="&#xe092;" horiz-adv-x="600"
d="M0 700h200v-600h-200v600zM400 700h200v-600h-200v600z" />
<glyph glyph-name="93" unicode="&#xe093;" horiz-adv-x="600"
d="M0 700l600 -300l-600 -300v600z" />
<glyph glyph-name="94" unicode="&#xe094;" horiz-adv-x="600"
d="M300 700c166 0 300 -134 300 -300s-134 -300 -300 -300s-300 134 -300 300s134 300 300 300z" />
<glyph glyph-name="95" unicode="&#xe095;"
d="M400 700v-600l-400 300zM400 400l400 300v-600z" />
<glyph glyph-name="96" unicode="&#xe096;"
d="M0 700l400 -300l-400 -300v600zM400 100v600l400 -300z" />
<glyph glyph-name="97" unicode="&#xe097;"
d="M0 700h200v-600h-200v600zM200 400l500 300v-600z" />
<glyph glyph-name="98" unicode="&#xe098;"
d="M0 700l500 -300l-500 -300v600zM500 100v600h200v-600h-200z" />
<glyph glyph-name="99" unicode="&#xe099;" horiz-adv-x="600"
d="M0 700h600v-600h-600v600z" />
<glyph glyph-name="9a" unicode="&#xe09a;"
d="M200 800h400v-200h200v-400h-200v-200h-400v200h-200v400h200v200z" />
<glyph glyph-name="9b" unicode="&#xe09b;"
d="M0 700h800v-100h-800v100zM0 403h800v-100h-800v100zM0 103h800v-100h-800v100z" />
<glyph glyph-name="9c" unicode="&#xe09c;" horiz-adv-x="600"
d="M278 700c7 2 13 4 22 4c55 0 100 -45 100 -100v-4v-200c0 -55 -45 -100 -100 -100s-100 45 -100 100v200v2c0 44 35 88 78 98zM34 500h4h3c3 0 6 1 9 1c28 0 50 -22 50 -50v-1v-50c0 -111 89 -200 200 -200s200 89 200 200v50c0 28 22 50 50 50s50 -22 50 -50v-50
c0 -148 -109 -270 -250 -294v-106h50c55 0 100 -45 100 -100h-400c0 55 45 100 100 100h50v106c-141 24 -250 146 -250 294v50v2c0 20 15 42 34 48z" />
<glyph glyph-name="9d" unicode="&#xe09d;"
d="M0 500h800v-200h-800v200z" />
<glyph glyph-name="9e" unicode="&#xe09e;"
d="M34 700h4h3h4h5h700c28 0 50 -22 50 -50v-500c0 -28 -22 -50 -50 -50h-250v-100h100c55 0 100 -45 100 -100h-600c0 55 45 100 100 100h100v100h-250c-28 0 -50 22 -50 50v500v2c0 20 15 42 34 48zM100 600v-400h600v400h-600z" />
<glyph glyph-name="9f" unicode="&#xe09f;"
d="M272 700c-14 -40 -22 -83 -22 -128c0 -221 179 -400 400 -400c45 0 88 8 128 22c-53 -158 -202 -272 -378 -272c-221 0 -400 179 -400 400c0 176 114 325 272 378z" />
<glyph glyph-name="a0" unicode="&#xe0a0;"
d="M350 700l150 -150h-100v-150h150v100l150 -150l-150 -150v100h-150v-150h100l-150 -150l-150 150h100v150h-150v-100l-150 150l150 150v-100h150v150h-100z" />
<glyph glyph-name="a1" unicode="&#xe0a1;"
d="M800 800v-550c0 -83 -67 -150 -150 -150s-150 67 -150 150s67 150 150 150c17 0 35 -4 50 -9v206c-201 -6 -327 -27 -400 -50v-397c0 -83 -67 -150 -150 -150s-150 67 -150 150s67 150 150 150c17 0 35 -4 50 -9v409s100 100 600 100z" />
<glyph glyph-name="a2" unicode="&#xe0a2;" horiz-adv-x="700"
d="M499 700c51 0 102 -20 141 -59c78 -78 78 -203 0 -281l-250 -244c-48 -48 -127 -48 -175 0s-48 127 0 175l96 97l69 -69l-90 -94l-7 -3c-10 -10 -10 -28 0 -38s28 -10 38 0l250 247c37 40 39 102 0 141s-104 40 -144 0l-278 -275c-66 -69 -68 -179 0 -247
c69 -69 181 -69 250 0l9 12l116 113l69 -69l-125 -125c-107 -107 -281 -107 -388 0s-107 281 0 388l278 272c39 39 90 59 141 59z" />
<glyph glyph-name="a3" unicode="&#xe0a3;"
d="M600 800l200 -200l-100 -100l-200 200zM400 600l200 -200l-400 -400h-200v200z" />
<glyph glyph-name="a4" unicode="&#xe0a4;"
d="M550 800c83 0 150 -90 150 -200s-67 -200 -150 -200c-22 0 -40 8 -59 19c6 26 9 52 9 81c0 84 -27 158 -72 212c27 52 71 88 122 88zM250 700c83 0 150 -90 150 -200s-67 -200 -150 -200s-150 90 -150 200s67 200 150 200zM725 384c44 -22 75 -66 75 -118v-166h-200v66
c0 50 -17 96 -44 134c66 2 126 33 169 84zM75 284c45 -53 106 -84 175 -84s130 31 175 84c44 -22 75 -66 75 -118v-166h-500v166c0 52 31 96 75 118z" />
<glyph glyph-name="a5" unicode="&#xe0a5;"
d="M400 800c110 0 200 -112 200 -250s-90 -250 -200 -250s-200 112 -200 250s90 250 200 250zM191 300c54 -61 128 -100 209 -100s155 39 209 100c106 -5 191 -92 191 -200v-100h-800v100c0 108 85 195 191 200z" />
<glyph glyph-name="a6" unicode="&#xe0a6;" horiz-adv-x="600"
d="M19 800h462c11 0 19 -8 19 -19v-762c0 -11 -8 -19 -19 -19h-462c-11 0 -19 8 -19 19v762c0 11 8 19 19 19zM100 700v-500h300v500h-300zM250 150c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="a7" unicode="&#xe0a7;"
d="M350 800c17 0 34 -1 50 -3v-397l-297 297c63 64 150 103 247 103zM500 694c169 -25 300 -168 300 -344c0 -193 -157 -350 -350 -350c-85 0 -161 31 -222 81l272 272v341zM91 562l237 -234l-212 -212c-70 55 -116 138 -116 234c0 84 35 158 91 212z" />
<glyph glyph-name="a8" unicode="&#xe0a8;"
d="M92 650c0 23 20 50 46 50h3h4h5h400c28 0 50 -22 50 -50s-22 -50 -50 -50h-50v-200h100c55 0 100 -45 100 -100h-300v-300l-56 -100l-44 100v300h-300c0 55 45 100 100 100h100v200h-50c-2 0 -6 -1 -8 -1c-28 0 -50 23 -50 51z" />
<glyph glyph-name="a9" unicode="&#xe0a9;"
d="M400 800c221 0 400 -179 400 -400s-179 -400 -400 -400s-400 179 -400 400s179 400 400 400zM300 600v-400l300 200z" />
<glyph glyph-name="aa" unicode="&#xe0aa;"
d="M300 800h200v-300h300v-200h-300v-300h-200v300h-300v200h300v300z" />
<glyph glyph-name="ab" unicode="&#xe0ab;"
d="M300 800h100v-400h-100v400zM172 656l62 -78l-40 -31c-58 -46 -94 -117 -94 -197c0 -139 111 -250 250 -250s250 111 250 250c0 80 -39 151 -97 197l-37 31l62 78l38 -31c82 -64 134 -164 134 -275c0 -193 -157 -350 -350 -350s-350 157 -350 350c0 111 53 211 134 275z
" />
<glyph glyph-name="ac" unicode="&#xe0ac;"
d="M200 800h400v-200h-400v200zM9 500h782c6 0 9 -3 9 -9v-282c0 -6 -3 -9 -9 -9h-91v200h-600v-200h-91c-6 0 -9 3 -9 9v282c0 6 3 9 9 9zM200 300h400v-300h-400v300z" />
<glyph glyph-name="ad" unicode="&#xe0ad;"
d="M0 700h100v-700h-100v700zM700 700h100v-700h-100v700zM200 600h200v-100h-200v100zM300 400h200v-100h-200v100zM400 200h200v-100h-200v100z" />
<glyph glyph-name="ae" unicode="&#xe0ae;"
d="M325 700c42 -141 87 -280 131 -419c29 74 59 148 88 222c30 -57 58 -114 87 -172h169v-100h-231l-13 28c-37 -92 -74 -184 -112 -275c-38 129 -79 257 -119 385c-42 -133 -83 -267 -125 -400c-28 88 -56 175 -84 262h-116v100h188l9 -34l3 -6c42 137 83 273 125 409z" />
<glyph glyph-name="af" unicode="&#xe0af;"
d="M200 600c0 57 43 100 100 100s100 -43 100 -100c0 -28 -18 -48 -28 -72c-3 -6 -3 -16 -3 -28h231v-231c12 0 22 0 28 3c24 10 44 28 72 28c57 0 100 -43 100 -100s-43 -100 -100 -100c-28 0 -48 18 -72 28c-6 3 -16 3 -28 3v-231h-231c0 12 0 22 3 28c10 24 28 44 28 72
c0 57 -43 100 -100 100s-100 -43 -100 -100c0 -28 18 -48 28 -72c3 -6 3 -16 3 -28h-231v600h231c0 12 0 22 -3 28c-10 24 -28 44 -28 72z" />
<glyph glyph-name="b0" unicode="&#xe0b0;" horiz-adv-x="500"
d="M247 700c84 0 148 -20 191 -59s59 -93 59 -141c0 -117 -69 -181 -119 -225s-81 -67 -81 -150v-25h-100v25c0 117 65 181 115 225s85 67 85 150c0 25 -8 48 -28 66s-56 34 -122 34s-97 -18 -116 -37s-27 -43 -31 -69l-100 12c5 38 19 88 59 128s103 66 188 66zM197 0h100
v-100h-100v100z" />
<glyph glyph-name="b1" unicode="&#xe0b1;"
d="M450 800c138 0 250 -112 250 -250v-50c58 -21 100 -85 100 -150c0 -69 -48 -127 -112 -144c-22 55 -75 94 -138 94c-20 0 -39 -5 -56 -12c-17 64 -75 112 -144 112s-127 -48 -144 -112c-17 7 -36 12 -56 12c-37 0 -71 -12 -97 -34c-33 36 -53 82 -53 134
c0 110 90 200 200 200c23 114 129 200 250 200zM334 300h4h3c3 0 6 1 9 1c28 0 50 -22 50 -50v-1v-200c0 -28 -22 -50 -50 -50s-50 22 -50 50v200v2c0 20 15 42 34 48zM134 200h4h3c3 0 6 1 9 1c28 0 50 -22 50 -50v-1v-100c0 -28 -22 -50 -50 -50s-50 22 -50 50v100v2
c0 20 15 42 34 48zM534 200h3h4c3 0 6 1 9 1c28 0 50 -22 50 -50v-1v-100c0 -28 -22 -50 -50 -50s-50 22 -50 50v100v2c0 20 15 42 34 48z" />
<glyph glyph-name="b2" unicode="&#xe0b2;"
d="M600 800l200 -150l-200 -150v100h-50l-153 -191l175 -206l6 -3h22v100l200 -150l-200 -150v100h-25c-35 0 -56 12 -78 38l-166 190l-153 -190c-22 -27 -43 -38 -78 -38h-100v100h100l166 206l-163 191l-3 3h-100v100h100c34 0 56 -12 78 -38l153 -178l141 178
c22 27 43 38 78 38h50v100z" />
<glyph glyph-name="b3" unicode="&#xe0b3;"
d="M400 800c110 0 209 -47 281 -119l119 119v-300h-300l109 109c-54 55 -126 91 -209 91c-166 0 -300 -134 -300 -300s134 -300 300 -300c83 0 158 34 212 88l72 -72c-72 -72 -174 -116 -284 -116c-220 0 -400 180 -400 400s180 400 400 400z" />
<glyph glyph-name="b4" unicode="&#xe0b4;"
d="M400 800h400v-400l-166 166l-400 -400l166 -166h-400v400l166 -166l400 400z" />
<glyph glyph-name="b5" unicode="&#xe0b5;" horiz-adv-x="600"
d="M250 800l250 -300h-200v-200h200l-250 -300l-250 300h200v200h-200z" />
<glyph glyph-name="b6" unicode="&#xe0b6;"
d="M300 600v-200h200v200l300 -250l-300 -250v200h-200v-200l-300 250z" />
<glyph glyph-name="b7" unicode="&#xe0b7;"
d="M0 800c441 0 800 -359 800 -800h-200c0 333 -267 600 -600 600v200zM0 500c275 0 500 -225 500 -500h-200c0 167 -133 300 -300 300v200zM0 200c110 0 200 -90 200 -200h-200v200z" />
<glyph glyph-name="b8" unicode="&#xe0b8;"
d="M100 800c386 0 700 -314 700 -700h-100c0 332 -268 600 -600 600v100zM100 600c276 0 500 -224 500 -500h-100c0 222 -178 400 -400 400v100zM100 400c165 0 300 -135 300 -300h-100c0 111 -89 200 -200 200v100zM100 200c55 0 100 -45 100 -100s-45 -100 -100 -100
s-100 45 -100 100s45 100 100 100z" />
<glyph glyph-name="b9" unicode="&#xe0b9;"
d="M300 800h400c55 0 100 -45 100 -100v-200h-400v150c0 28 -22 50 -50 50s-50 -22 -50 -50v-250h400v-300c0 -55 -45 -100 -100 -100h-500c-55 0 -100 45 -100 100v200h100v-150c0 -28 22 -50 50 -50s50 22 50 50v550c0 55 45 100 100 100z" />
<glyph glyph-name="ba" unicode="&#xe0ba;"
d="M75 700h225v-100h-200v-500h400v100h100v-125c0 -41 -34 -75 -75 -75h-450c-41 0 -75 34 -75 75v550c0 41 34 75 75 75zM600 700l200 -200l-200 -200v100h-200c-94 0 -173 -65 -194 -153c23 199 189 353 394 353v100z" />
<glyph glyph-name="bb" unicode="&#xe0bb;"
d="M500 700l300 -284l-300 -316v200h-100c-200 0 -348 -102 -400 -300c0 295 100 500 500 500v200z" />
<glyph glyph-name="bc" unicode="&#xe0bc;"
d="M381 791l19 9l19 -9c127 -53 253 -108 381 -160v-31c0 -166 -67 -313 -147 -419c-40 -53 -83 -97 -125 -128s-82 -53 -128 -53s-86 22 -128 53s-85 75 -125 128c-80 107 -147 253 -147 419v31c128 52 254 107 381 160zM400 100v591l-294 -122c8 -126 58 -243 122 -328
c35 -46 73 -86 106 -110s62 -31 66 -31z" />
<glyph glyph-name="bd" unicode="&#xe0bd;"
d="M600 800h100v-800h-100v800zM400 700h100v-700h-100v700zM200 500h100v-500h-100v500zM0 300h100v-300h-100v300z" />
<glyph glyph-name="be" unicode="&#xe0be;"
d="M300 800h100v-200h200l100 -100l-100 -100h-200v-400h-100v500h-200l-100 100l100 100h200v100z" />
<glyph glyph-name="bf" unicode="&#xe0bf;"
d="M200 800h100v-600h200l-250 -200l-250 200h200v600zM400 800h200v-100h-200v100zM400 600h300v-100h-300v100zM400 400h400v-100h-400v100z" />
<glyph glyph-name="c0" unicode="&#xe0c0;"
d="M200 800h100v-600h200l-250 -200l-250 200h200v600zM400 800h400v-100h-400v100zM400 600h300v-100h-300v100zM400 400h200v-100h-200v100z" />
<glyph glyph-name="c1" unicode="&#xe0c1;"
d="M75 700h650c41 0 75 -34 75 -75v-550c0 -41 -34 -75 -75 -75h-650c-41 0 -75 34 -75 75v550c0 41 34 75 75 75zM100 600v-100h100v100h-100zM300 600v-100h400v100h-400zM100 400v-100h100v100h-100zM300 400v-100h400v100h-400zM100 200v-100h100v100h-100zM300 200
v-100h400v100h-400z" />
<glyph glyph-name="c2" unicode="&#xe0c2;"
d="M400 800l100 -300h300l-250 -200l100 -300l-250 200l-250 -200l100 300l-250 200h300z" />
<glyph glyph-name="c3" unicode="&#xe0c3;"
d="M400 800c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM150 700c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM650 700c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM400 600c110 0 200 -90 200 -200
s-90 -200 -200 -200s-200 90 -200 200s90 200 200 200zM50 450c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM750 450c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM150 200c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50
s22 50 50 50zM650 200c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50zM400 100c28 0 50 -22 50 -50s-22 -50 -50 -50s-50 22 -50 50s22 50 50 50z" />
<glyph glyph-name="c4" unicode="&#xe0c4;"
d="M34 800h632c18 0 34 -16 34 -34v-732c0 -18 -16 -34 -34 -34h-632c-18 0 -34 16 -34 34v732c0 18 16 34 34 34zM100 700v-500h500v500h-500zM350 150c-38 0 -63 -42 -44 -75s69 -33 88 0s-6 75 -44 75z" />
<glyph glyph-name="c5" unicode="&#xe0c5;"
d="M0 800h300l500 -500l-300 -300l-500 500v300zM200 700c-55 0 -100 -45 -100 -100s45 -100 100 -100s100 45 100 100s-45 100 -100 100z" />
<glyph glyph-name="c6" unicode="&#xe0c6;"
d="M0 600h200l300 -300l-200 -200l-300 300v200zM340 600h160l300 -300l-200 -200l-78 78l119 122zM150 500c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="c7" unicode="&#xe0c7;"
d="M400 800c220 0 400 -180 400 -400s-180 -400 -400 -400s-400 180 -400 400s180 400 400 400zM400 700c-166 0 -300 -134 -300 -300s134 -300 300 -300s300 134 300 300s-134 300 -300 300zM400 600c110 0 200 -90 200 -200s-90 -200 -200 -200s-200 90 -200 200
s90 200 200 200zM400 500c-56 0 -100 -44 -100 -100s44 -100 100 -100s100 44 100 100s-44 100 -100 100z" />
<glyph glyph-name="c8" unicode="&#xe0c8;"
d="M0 700h559l-100 -100h-359v-500h500v159l100 100v-359h-700v700zM700 700l100 -100l-400 -400l-200 200l100 100l100 -100z" />
<glyph glyph-name="c9" unicode="&#xe0c9;"
d="M9 800h782c6 0 9 -3 9 -9v-782c0 -6 -3 -9 -9 -9h-782c-6 0 -9 3 -9 9v782c0 6 3 9 9 9zM150 722l-72 -72l100 -100l-100 -100l72 -72l172 172zM400 500v-100h300v100h-300z" />
<glyph glyph-name="ca" unicode="&#xe0ca;"
d="M0 800h800v-200h-50c0 55 -45 100 -100 100h-150v-550c0 -28 22 -50 50 -50h50v-100h-400v100h50c28 0 50 22 50 50v550h-150c-55 0 -100 -45 -100 -100h-50v200z" />
<glyph glyph-name="cb" unicode="&#xe0cb;"
d="M0 700h100v-400h-100v400zM200 700h350c21 0 39 -13 47 -31c0 0 103 -291 103 -319s-22 -50 -50 -50h-150c-28 0 -50 -25 -50 -50s39 -158 47 -184s-5 -55 -31 -63s-52 5 -66 31s-109 219 -128 238s-44 28 -72 28v400z" />
<glyph glyph-name="cc" unicode="&#xe0cc;"
d="M400 666c10 19 28 32 47 34l19 -3c26 -8 39 -37 31 -63s-47 -159 -47 -184s22 -50 50 -50h150c28 0 50 -22 50 -50s-103 -319 -103 -319c-8 -18 -26 -31 -47 -31h-350v400c28 0 53 9 72 28s114 212 128 238zM0 400h100v-400h-100v400z" />
<glyph glyph-name="cd" unicode="&#xe0cd;"
d="M200 700h300v-100h-100v-6c25 -4 50 -8 72 -16l-34 -94c-28 11 -58 16 -88 16c-139 0 -250 -111 -250 -250s111 -250 250 -250s250 111 250 250c0 31 -5 60 -16 88l91 37c14 -38 25 -81 25 -125c0 -193 -157 -350 -350 -350s-350 157 -350 350c0 176 130 323 300 347v3
h-100v100zM700 584c0 0 -296 -348 -316 -368s-48 -20 -68 0s-20 48 0 68s384 300 384 300z" />
<glyph glyph-name="ce" unicode="&#xe0ce;"
d="M600 700l200 -150l-200 -150v100h-600v100h600v100zM200 300v-100h600v-100h-600v-100l-200 150z" />
<glyph glyph-name="cf" unicode="&#xe0cf;"
d="M300 800h100c55 0 100 -45 100 -100h100c55 0 100 -45 100 -100h-700c0 55 45 100 100 100h100c0 55 45 100 100 100zM100 500h100v-350c0 -28 22 -50 50 -50s50 22 50 50v350h100v-350c0 -28 22 -50 50 -50s50 22 50 50v350h100v-481c0 -11 -8 -19 -19 -19h-462
c-11 0 -19 8 -19 19v481z" />
<glyph glyph-name="d0" unicode="&#xe0d0;"
d="M100 800h200v-400c0 -55 45 -100 100 -100s100 45 100 100v400h100v-400c0 -110 -90 -200 -200 -200h-50c-138 0 -250 90 -250 200v400zM0 100h700v-100h-700v100z" />
<glyph glyph-name="d1" unicode="&#xe0d1;"
d="M9 700h182c6 0 9 -3 9 -9v-482c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v482c0 6 3 9 9 9zM609 700h182c6 0 9 -3 9 -9v-482c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v482c0 6 3 9 9 9zM309 500h182c6 0 9 -3 9 -9v-282c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v282
c0 6 3 9 9 9zM0 100h800v-100h-800v100z" />
<glyph glyph-name="d2" unicode="&#xe0d2;"
d="M10 700h181c6 0 9 -3 9 -9v-191h-200v191c0 6 4 9 10 9zM610 700h181c6 0 9 -3 9 -9v-191h-200v191c0 6 5 9 10 9zM310 600h181c6 0 9 -3 9 -9v-91h-200v91c0 6 4 9 10 9zM0 400h800v-100h-800v100zM0 200h200v-191c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v191zM300 200
h200v-91c0 -6 -3 -9 -9 -9h-181c-6 0 -10 3 -10 9v91zM600 200h200v-191c0 -6 -3 -9 -9 -9h-181c-6 0 -10 3 -10 9v191z" />
<glyph glyph-name="d3" unicode="&#xe0d3;"
d="M0 700h800v-100h-800v100zM9 500h182c6 0 9 -3 9 -9v-482c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v482c0 6 3 9 9 9zM309 500h182c6 0 9 -3 9 -9v-282c0 -6 -3 -9 -9 -9h-182c-6 0 -9 3 -9 9v282c0 6 3 9 9 9zM609 500h182c6 0 9 -3 9 -9v-482c0 -6 -3 -9 -9 -9h-182
c-6 0 -9 3 -9 9v482c0 6 3 9 9 9z" />
<glyph glyph-name="d4" unicode="&#xe0d4;"
d="M50 600h500c28 0 50 -22 50 -50v-150l100 100h100v-300h-100l-100 100v-150c0 -28 -22 -50 -50 -50h-500c-28 0 -50 22 -50 50v400c0 28 22 50 50 50z" />
<glyph glyph-name="d5" unicode="&#xe0d5;"
d="M334 800h66v-800h-66l-134 200h-200v400h200zM500 600v100c26 0 52 -4 75 -10c130 -33 225 -150 225 -290s-95 -258 -225 -291h-3c-23 -6 -47 -9 -72 -9v100c17 0 34 2 50 6c86 22 150 100 150 194s-64 172 -150 194c-16 4 -33 6 -50 6zM500 500l25 -3
c44 -11 75 -51 75 -97s-32 -86 -75 -97l-25 -3v200z" />
<glyph glyph-name="d6" unicode="&#xe0d6;" horiz-adv-x="600"
d="M334 800h66v-800h-66l-134 200h-200v400h200zM500 500l25 -3c44 -11 75 -51 75 -97s-32 -86 -75 -97l-25 -3v200z" />
<glyph glyph-name="d7" unicode="&#xe0d7;" horiz-adv-x="400"
d="M334 800h66v-800h-66l-134 200h-200v400h200z" />
<glyph glyph-name="d8" unicode="&#xe0d8;"
d="M309 800h82c6 0 10 -4 12 -9l294 -682l3 -19v-81c0 -6 -3 -9 -9 -9h-682c-6 0 -9 3 -9 9v81l3 19l294 682c2 5 6 9 12 9zM300 500v-200h100v200h-100zM300 200v-100h100v100h-100z" />
<glyph glyph-name="d9" unicode="&#xe0d9;"
d="M375 800c138 0 269 -39 378 -109l-53 -82c-93 60 -205 91 -325 91c-119 0 -229 -32 -322 -91l-53 82c109 70 237 109 375 109zM375 500c78 0 154 -23 216 -62l-53 -85c-46 30 -104 47 -163 47c-60 0 -112 -17 -159 -47l-54 85c62 40 134 62 213 62zM375 200
c55 0 100 -45 100 -100s-45 -100 -100 -100s-100 45 -100 100s45 100 100 100z" />
<glyph glyph-name="da" unicode="&#xe0da;" horiz-adv-x="900"
d="M551 800c16 0 32 0 47 -3l-97 -97v-200h200l97 97c3 -15 3 -31 3 -47c0 -138 -112 -250 -250 -250c-32 0 -62 8 -90 19l-288 -291c-20 -20 -46 -28 -72 -28s-52 8 -72 28c-39 39 -39 105 0 144l291 287c-11 28 -19 59 -19 91c0 138 112 250 250 250zM101 150
c-28 0 -50 -22 -50 -50s22 -50 50 -50s50 22 50 50s-22 50 -50 50z" />
<glyph glyph-name="db" unicode="&#xe0db;"
d="M141 700c84 -84 169 -167 253 -250c82 83 167 165 247 250l143 -141l-253 -253c84 -82 167 -166 253 -247l-143 -143c-81 86 -165 169 -247 253l-253 -253l-141 143c85 80 167 164 250 247c-83 84 -166 169 -250 253z" />
<glyph glyph-name="dc" unicode="&#xe0dc;"
d="M0 800h100l231 -300h38l231 300h100l-225 -300h225v-100h-300v-100h300v-100h-300v-200h-100v200h-300v100h300v100h-300v100h225z" />
<glyph glyph-name="dd" unicode="&#xe0dd;" horiz-adv-x="900"
d="M350 800c193 0 350 -157 350 -350c0 -61 -17 -119 -44 -169c4 -2 10 -6 13 -9l103 -100c16 -16 30 -49 30 -72c0 -56 -46 -102 -102 -102c-23 0 -56 14 -72 30l-100 103c-3 3 -7 9 -9 13c-50 -28 -108 -44 -169 -44c-193 0 -350 157 -350 350s157 350 350 350zM350 700
c-139 0 -250 -111 -250 -250s111 -250 250 -250c62 0 119 23 163 60c7 11 19 25 31 31l3 3c34 43 53 97 53 156c0 139 -111 250 -250 250zM300 600h100v-100h100v-100h-100v-100h-100v100h-100v100h100v100z" />
<glyph glyph-name="de" unicode="&#xe0de;" horiz-adv-x="900"
d="M350 800c193 0 350 -157 350 -350c0 -61 -17 -119 -44 -169c4 -2 10 -6 13 -9l103 -100c16 -16 30 -49 30 -72c0 -56 -46 -102 -102 -102c-23 0 -56 14 -72 30l-100 103c-3 3 -7 9 -9 13c-50 -28 -108 -44 -169 -44c-193 0 -350 157 -350 350s157 350 350 350zM350 700
c-139 0 -250 -111 -250 -250s111 -250 250 -250c62 0 119 23 163 60c7 11 19 25 31 31l3 3c34 43 53 97 53 156c0 139 -111 250 -250 250zM200 500h300v-100h-300v100z" />
</font>
</defs></svg>

После

Ширина:  |  Высота:  |  Размер: 54 KiB

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,205 @@
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
html, body {
font-family: "Roboto",sans-serif;
}
a, .btn-link {
color: #0366d6;
}
.btn-primary {
color: #fff;
background-color: #3371e3;
border-color: #303030;
}
app {
position: relative;
display: flex;
flex-direction: column;
}
.top-row {
height: 3.5rem;
display: flex;
align-items: center;
}
.main {
flex: 1;
}
.main .top-row {
background-color: #303030;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
}
.main .top-row > a, .main .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}
.main .top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
.sidebar {
background-image: linear-gradient(180deg, #000 0%, #333 50%);
}
.sidebar .top-row {
background-color: #303030;
}
.sidebar .navbar-brand {
font-size: 1.1rem;
}
.sidebar .oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}
.sidebar .nav-item, top-nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.sidebar .nav-item:first-of-type {
padding-top: 1rem;
}
.sidebar .nav-item:last-of-type {
padding-bottom: 1rem;
}
.sidebar .nav-item a, .top-nav-item a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
background-color: #3371e3;
}
.sidebar .nav-item a.active, .top-nav-item a.active {
background-color: #0366d6;
color: white;
}
.sidebar .nav-item a:hover, .top-nav-item a:hover {
background-color: rgba(255,255,255,0.1);
transition: 0.3s;
color: white;
}
button.navbar-toggler {
color: white;
background-color: #303030;
}
button.navbar-toggler:hover {
color: #3371e3;
background-color: #3371e3;
transition: 0.3s;
}
.top-nav-item a {
padding-left: 2rem;
padding-right: 2rem;
text-decoration: none;
background-color: #303030;
border: 1px solid rgba(255,255,255,.1);
border-radius: .25rem;
}
.content {
padding-top: 1.1rem;
}
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}
.valid.modified:not([type=checkbox]) {
outline: 1px solid #26b050;
}
.invalid {
outline: 1px solid red;
}
.validation-message {
color: red;
}
#blazor-error-ui {
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
@media (max-width: 767.98px) {
.main .top-row:not(.auth) {
display: none;
}
.main .top-row.auth {
justify-content: space-between;
}
.main .top-row a, .main .top-row .btn-link {
margin-left: 0;
}
}
@media (min-width: 768px) {
app {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.main .top-row {
position: sticky;
top: 0;
}
.main > div {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
.navbar-toggler {
display: none;
}
.sidebar .collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}

Двоичные данные
src/micronetes/Micronetes.Hosting/wwwroot/favicon.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 15 KiB

Просмотреть файл

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve">
<style type="text/css">
.st0{display:none;fill:#2B3544;}
.st1{fill:#4F5D73;}
.st2{opacity:0.2;}
.st3{fill:#231F20;}
.st4{fill:none;stroke:#E0995E;stroke-width:4;stroke-linecap:round;stroke-miterlimit:10;}
.st5{opacity:0.2;fill:#231F20;}
.st6{fill:#F5CF87;}
.st7{fill:none;stroke:#F5CF87;stroke-width:4;stroke-miterlimit:10;}
</style>
<rect x="-391" y="-1345" class="st0" width="608" height="1984"/>
<circle class="st1" cx="32" cy="32" r="32"/>
<g class="st2">
<g>
<path class="st3" d="M32,60c-1.1,0-2-0.9-2-2V10c0-1.1,0.9-2,2-2s2,0.9,2,2v48C34,59.1,33.1,60,32,60z"/>
</g>
<g>
<path class="st3" d="M56,36H8c-1.1,0-2-0.9-2-2s0.9-2,2-2h48c1.1,0,2,0.9,2,2S57.1,36,56,36z"/>
</g>
<g>
<path class="st3" d="M49,53c-0.5,0-1-0.2-1.4-0.6L13.6,18.4c-0.8-0.8-0.8-2,0-2.8c0.8-0.8,2-0.8,2.8,0l33.9,33.9
c0.8,0.8,0.8,2,0,2.8C50,52.8,49.5,53,49,53z"/>
</g>
<g>
<path class="st3" d="M15,53c-0.5,0-1-0.2-1.4-0.6c-0.8-0.8-0.8-2,0-2.8l33.9-33.9c0.8-0.8,2-0.8,2.8,0c0.8,0.8,0.8,2,0,2.8
L16.4,52.4C16.1,52.8,15.5,53,15,53z"/>
</g>
</g>
<g>
<line class="st4" x1="32" y1="8" x2="32" y2="56"/>
<line class="st4" x1="56" y1="32" x2="8" y2="32"/>
<line class="st4" x1="49" y1="49" x2="15" y2="15"/>
<line class="st4" x1="15" y1="49" x2="49" y2="15"/>
</g>
<path class="st5" d="M32,18c8.8,0,16,7.2,16,16s-7.2,16-16,16s-16-7.2-16-16S23.2,18,32,18 M32,14c-11,0-20,9-20,20s9,20,20,20
s20-9,20-20S43,14,32,14L32,14z"/>
<g>
<path class="st6" d="M32,16c8.8,0,16,7.2,16,16s-7.2,16-16,16s-16-7.2-16-16S23.2,16,32,16 M32,12c-11,0-20,9-20,20s9,20,20,20
s20-9,20-20S43,12,32,12L32,12z"/>
</g>
<circle class="st1" cx="32" cy="32" r="6"/>
<g class="st2">
<path class="st3" d="M32,44c-5.5,0-10-4.5-10-10s4.5-10,10-10s10,4.5,10,10S37.5,44,32,44z M32,28c-3.3,0-6,2.7-6,6s2.7,6,6,6
s6-2.7,6-6S35.3,28,32,28z"/>
</g>
<circle class="st7" cx="32" cy="32" r="8"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

@ -0,0 +1,259 @@
using System;
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;
using System.CommandLine.IO;
using System.CommandLine.Parsing;
using System.CommandLine.Rendering;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Micronetes.Hosting;
using Micronetes.Hosting.Model;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace Micronetes.Host
{
class Program
{
static async Task<int> Main(string[] args)
{
var command = new RootCommand();
command.Add(RunCommand(args));
command.Add(NewCommand());
command.Description = "Process manager and orchestrator for microservices.";
var builder = new CommandLineBuilder(command);
builder.UseHelp();
builder.UseVersionOption();
builder.UseDebugDirective();
builder.UseParseErrorReporting();
builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
builder.UsePrefixes(new[] { "-", "--", }); // disable garbage windows conventions
builder.CancelOnProcessTermination();
builder.UseExceptionHandler(HandleException);
// Allow fancy drawing.
builder.UseAnsiTerminalWhenAvailable();
var parser = builder.Build();
return await parser.InvokeAsync(args);
}
private static Command NewCommand()
{
var command = new Command("new", "create a yaml manifest")
{
};
var argument = new Argument("path")
{
Description = "A solution or project file to generate a yaml manifest from",
Arity = ArgumentArity.ZeroOrOne
};
command.AddArgument(argument);
command.Handler = CommandHandler.Create<IConsole, string>((console, path) =>
{
if (File.Exists("m8s.yaml"))
{
console.Out.WriteLine("\"m8s.yaml\" already exists.");
return;
}
var template = @"- name: app
# project: app.csproj # msbuild project path (relative to this file)
# executable: app.exe # path to an executable (relative to this file)
# args: --arg1=3 # arguments to pass to the process
# replicas: 5 # number of times to launch the application
# env: # array of environment variables
# - name: key
# value: value
# bindings: # optional array of bindings (ports, connection strings)
# - port: 8080 # number port of the binding
";
try
{
if (!string.IsNullOrEmpty(path))
{
var application = ResolveApplication(path);
var serializer = new SerializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitDefaults)
.Build();
var extension = Path.GetExtension(application.Source).ToLowerInvariant();
var directory = Path.GetDirectoryName(application.Source);
var descriptions = application.Services.Select(s => s.Value.Description).ToList();
// Clear all bindings if any for solutions and project files
if (extension == ".sln" || extension == ".csproj" || extension == ".fsproj")
{
foreach (var d in descriptions)
{
d.Bindings = null;
d.Replicas = null;
d.Build = null;
d.Configuration = null;
d.Project = d.Project.Substring(directory.Length).TrimStart(Path.DirectorySeparatorChar);
}
}
template = serializer.Serialize(descriptions);
}
}
catch (FileNotFoundException)
{
// No file found, just generate a new one
}
File.WriteAllText("m8s.yaml", template);
console.Out.WriteLine("Created \"m8s.yaml\"");
});
return command;
}
private static Command RunCommand(string[] args)
{
var command = new Command("run", "run the application")
{
};
var argument = new Argument("path")
{
Description = "A file or directory to execute. Supports a project files, solution files or a yaml manifest.",
Arity = ArgumentArity.ZeroOrOne
};
// TODO: We'll need to support a --build-args
command.AddOption(new Option("--no-build")
{
Description = "Do not build project files before running.",
Required = false
});
command.AddOption(new Option("--port")
{
Description = "The port to run control plane on.",
Argument = new Argument<int>("port"),
Required = false
});
command.AddOption(new Option("--logs")
{
Description = "Write structured application logs to the specified log providers. Supported providers are console, elastic (Elasticsearch), ai (ApplicationInsights), seq.",
Argument = new Argument<string>("logs"),
Required = false
});
command.AddOption(new Option("--dtrace")
{
Description = "Write distributed traces to the specified providers. Supported providers are zipkin.",
Argument = new Argument<string>("logs"),
Required = false
});
command.AddOption(new Option("--debug")
{
Description = "Wait for debugger attach in all services.",
Required = false
});
command.AddArgument(argument);
command.Handler = CommandHandler.Create<IConsole, string>((console, path) =>
{
Application app = ResolveApplication(path);
return MicronetesHost.RunAsync(app, args);
});
return command;
}
private static Application ResolveApplication(string path)
{
if (string.IsNullOrEmpty(path))
{
path = ResolveFileFromDirectory(Directory.GetCurrentDirectory());
}
else if (Directory.Exists(path))
{
path = ResolveFileFromDirectory(Path.GetFullPath(path));
}
if (!File.Exists(path))
{
throw new FileNotFoundException($"{path} does not exist");
}
switch (Path.GetExtension(path).ToLower())
{
case ".yaml":
case ".yml":
return Application.FromYaml(path);
case ".csproj":
case ".fsproj":
return Application.FromProject(path);
case ".sln":
return Application.FromSolution(path);
default:
throw new NotSupportedException($"{path} not supported");
}
}
private static string ResolveFileFromDirectory(string basePath)
{
var formats = new[] { "m8s.yaml", "m8s.yml", "*.csproj", "*.fsproj", "*.sln" };
foreach (var format in formats)
{
var files = Directory.GetFiles(basePath, format);
if (files.Length == 0)
{
continue;
}
if (files.Length > 1)
{
throw new InvalidOperationException($"Ambiguous match found {string.Join(", ", files.Select(Path.GetFileName))}");
}
return files[0];
}
throw new InvalidOperationException($"None of the supported files were found (m8s.yaml, .csproj, .fsproj, .sln)");
}
private static void HandleException(Exception exception, InvocationContext context)
{
// context.Console.ResetTerminalForegroundColor();
// context.Console.SetTerminalForegroundColor(ConsoleColor.Red);
if (exception is OperationCanceledException)
{
context.Console.Error.WriteLine("operation canceled.");
}
else if (exception is TargetInvocationException tae)
{
context.Console.Error.WriteLine(tae.InnerException.Message);
}
else
{
context.Console.Error.WriteLine("unhandled exception: ");
context.Console.Error.WriteLine(exception.ToString());
}
// context.Console.ResetTerminalForegroundColor();
context.ResultCode = 1;
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"profiles": {
"dotnet-micronetes": {
"commandName": "Project"
}
}
}

Просмотреть файл

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackAsTool>true</PackAsTool>
<RootNamespace>Micronetes.Host</RootNamespace>
<AssemblyName>m8s</AssemblyName>
<ToolCommandName>m8s</ToolCommandName>
<Description>Local orchestrator for microservices.</Description>
<Nullable>disable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Micronetes.Hosting\Micronetes.Hosting.csproj" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" />
<PackageReference Include="System.Commandline.Rendering" Version="0.3.0-alpha.20070.2" />
</ItemGroup>
</Project>

63
tye.sln
Просмотреть файл

@ -17,6 +17,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Opulence", "src\opulence\Op
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-opulence", "src\opulence\dotnet-opulence\dotnet-opulence.csproj", "{BA03A616-4649-414D-A116-727D72F4BF50}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "micronetes", "micronetes", "{B2C364E4-969E-4770-BF5F-BE65D292F70A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Micronetes.Hosting", "src\micronetes\Micronetes.Hosting\Micronetes.Hosting.csproj", "{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Micronetes.Hosting.Diagnostics", "src\micronetes\Micronetes.Hosting.Diagnostics\Micronetes.Hosting.Diagnostics.csproj", "{CEBFC149-8162-4A0A-9AD4-40498B9172CD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Micronetes.Hosting.Runtime", "src\micronetes\Micronetes.Hosting.Runtime\Micronetes.Hosting.Runtime.csproj", "{34719884-1338-4965-BA2A-F98DB03733C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "m8s", "src\micronetes\m8s\m8s.csproj", "{01C77687-2E5E-4DB3-B88C-218FC706DC7D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -78,6 +88,54 @@ Global
{BA03A616-4649-414D-A116-727D72F4BF50}.Release|x64.Build.0 = Release|Any CPU
{BA03A616-4649-414D-A116-727D72F4BF50}.Release|x86.ActiveCfg = Release|Any CPU
{BA03A616-4649-414D-A116-727D72F4BF50}.Release|x86.Build.0 = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|x64.ActiveCfg = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|x64.Build.0 = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|x86.ActiveCfg = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Debug|x86.Build.0 = Debug|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|Any CPU.Build.0 = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|x64.ActiveCfg = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|x64.Build.0 = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|x86.ActiveCfg = Release|Any CPU
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7}.Release|x86.Build.0 = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|x64.ActiveCfg = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|x64.Build.0 = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|x86.ActiveCfg = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Debug|x86.Build.0 = Debug|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|Any CPU.Build.0 = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|x64.ActiveCfg = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|x64.Build.0 = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|x86.ActiveCfg = Release|Any CPU
{CEBFC149-8162-4A0A-9AD4-40498B9172CD}.Release|x86.Build.0 = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|x64.ActiveCfg = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|x64.Build.0 = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|x86.ActiveCfg = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Debug|x86.Build.0 = Debug|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|Any CPU.Build.0 = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|x64.ActiveCfg = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|x64.Build.0 = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|x86.ActiveCfg = Release|Any CPU
{34719884-1338-4965-BA2A-F98DB03733C2}.Release|x86.Build.0 = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|x64.ActiveCfg = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|x64.Build.0 = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|x86.ActiveCfg = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Debug|x86.Build.0 = Debug|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|Any CPU.Build.0 = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|x64.ActiveCfg = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|x64.Build.0 = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|x86.ActiveCfg = Release|Any CPU
{01C77687-2E5E-4DB3-B88C-218FC706DC7D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9BFE4070-D6D8-41F8-B92E-F85C3DCD7AB8} = {8C662D59-A3CB-466F-8E85-A8E6BA5E7601}
@ -85,5 +143,10 @@ Global
{E8219571-549D-4EFE-8E62-54082D707B9A} = {8C662D59-A3CB-466F-8E85-A8E6BA5E7601}
{0A8A0C69-49CB-462E-A7D4-605F78786EEF} = {E8219571-549D-4EFE-8E62-54082D707B9A}
{BA03A616-4649-414D-A116-727D72F4BF50} = {E8219571-549D-4EFE-8E62-54082D707B9A}
{B2C364E4-969E-4770-BF5F-BE65D292F70A} = {8C662D59-A3CB-466F-8E85-A8E6BA5E7601}
{0F4F5A86-DD27-4AF9-BF97-221EAD5040E7} = {B2C364E4-969E-4770-BF5F-BE65D292F70A}
{CEBFC149-8162-4A0A-9AD4-40498B9172CD} = {B2C364E4-969E-4770-BF5F-BE65D292F70A}
{34719884-1338-4965-BA2A-F98DB03733C2} = {B2C364E4-969E-4770-BF5F-BE65D292F70A}
{01C77687-2E5E-4DB3-B88C-218FC706DC7D} = {B2C364E4-969E-4770-BF5F-BE65D292F70A}
EndGlobalSection
EndGlobal