提交 b8d46b43 编写于 作者: L Lemon 提交者: wu-sheng

Update Readme and some docs (#149)

* rm InstallCommand

* Update docs

* Update Readme and docs
上级 4c257890
...@@ -5,10 +5,10 @@ SkyAPM C#/.NET instrument agent ...@@ -5,10 +5,10 @@ SkyAPM C#/.NET instrument agent
[Apache SkyWalking](https://github.com/apache/incubator-skywalking) is an APM designed for microservices, cloud native and container-based (Docker, K8s, Mesos) architectures. **SkyAPM-dotnet** provides the native support agent in C# and .NETStandard platform, with the helps from Apache SkyWalking committer team. [Apache SkyWalking](https://github.com/apache/incubator-skywalking) is an APM designed for microservices, cloud native and container-based (Docker, K8s, Mesos) architectures. **SkyAPM-dotnet** provides the native support agent in C# and .NETStandard platform, with the helps from Apache SkyWalking committer team.
![](https://img.shields.io/github/issues-raw/skyapm/skyapm-dotnet.svg?style=flat-square) [![issues](https://img.shields.io/github/issues-raw/skyapm/skyapm-dotnet.svg?style=flat-square)](https://github.com/SkyAPM/SkyAPM-dotnet/issues)
![](https://img.shields.io/github/issues-pr-raw/skyapm/skyapm-dotnet.svg?style=flat-square) [![pulls](https://img.shields.io/github/issues-pr-raw/skyapm/skyapm-dotnet.svg?style=flat-square)](https://github.com/SkyAPM/SkyAPM-dotnet/pulls)
![](https://img.shields.io/github/release/skyapm/skyapm-dotnet.svg?style=flat-square) [![releases](https://img.shields.io/github/release/skyapm/skyapm-dotnet.svg?style=flat-square)](https://github.com/SkyAPM/SkyAPM-dotnet/releases)
![](https://img.shields.io/gitter/room/openskywalking/lobby.svg?style=flat-square) [![Gitter](https://img.shields.io/gitter/room/openskywalking/lobby.svg?style=flat-square)](https://gitter.im/openskywalking/Lobby)
[![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=flat-square&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking) [![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=flat-square&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking)
## CI Build Status ## CI Build Status
...@@ -19,13 +19,15 @@ SkyAPM C#/.NET instrument agent ...@@ -19,13 +19,15 @@ SkyAPM C#/.NET instrument agent
## Nuget Packages ## Nuget Packages
| Package Name | Nuget | Myget | Downloads | Package Name | NuGet | MyGet | Downloads
|--------------| ------- | ------- | ---- |--------------| ------- | ------- | ----
| SkyAPM.Agent.AspNetCore | ![](https://img.shields.io/nuget/v/SkyAPM.Agent.AspNetCore.svg?style=flat-square) | ![](https://img.shields.io/myget/skyapm-dotnet/v/SkyAPM.Agent.AspNetCore.svg?style=flat-square) | ![](https://img.shields.io/nuget/dt/SkyAPM.Agent.AspNetCore.svg?style=flat-square) | SkyAPM.Agent.AspNetCore | [![nuget](https://img.shields.io/nuget/v/SkyAPM.Agent.AspNetCore.svg?style=flat-square)](https://www.nuget.org/packages/SkyAPM.Agent.AspNetCore) | [![myget](https://img.shields.io/myget/skyapm-dotnet/v/SkyAPM.Agent.AspNetCore.svg?style=flat-square)](https://www.myget.org/feed/skyapm-dotnet/package/nuget/SkyAPM.Agent.AspNetCore) | [![stats](https://img.shields.io/nuget/dt/SkyAPM.Agent.AspNetCore.svg?style=flat-square)](https://www.nuget.org/stats/packages/SkyAPM.Agent.AspNetCore?groupby=Version)
| SkyAPM.Agent.AspNet | ![](https://img.shields.io/nuget/v/SkyAPM.Agent.AspNet.svg?style=flat-square) | ![](https://img.shields.io/myget/skyapm-dotnet/v/SkyAPM.Agent.AspNet.svg?style=flat-square) | ![](https://img.shields.io/nuget/dt/SkyAPM.Agent.AspNet.svg?style=flat-square) | SkyAPM.Agent.AspNet | [![nuget](https://img.shields.io/nuget/v/SkyAPM.Agent.AspNet.svg?style=flat-square)](https://www.nuget.org/packages/SkyAPM.Agent.AspNet) | [![myget](https://img.shields.io/myget/skyapm-dotnet/v/SkyAPM.Agent.AspNet.svg?style=flat-square)](https://www.myget.org/feed/skyapm-dotnet/package/nuget/SkyAPM.Agent.AspNet) | [![](https://img.shields.io/nuget/dt/SkyAPM.Agent.AspNet.svg?style=flat-square)](https://www.nuget.org/stats/packages/SkyAPM.Agent.AspNet?groupby=Version)
> MyGet feed URL https://www.myget.org/F/skyapm-dotnet/api/v3/index.json
# Supported # Supported
- This project currently supports apps targeting netcoreapp2.0/.net framework4.6.1 or higher. - This project currently supports apps targeting netcoreapp2.0/netframework4.6.1 or higher.
- [Supported middlewares, frameworks and libraries.](docs/Supported-list.md) - [Supported middlewares, frameworks and libraries.](docs/Supported-list.md)
# Features # Features
......
# SkyWalking Configuration # SkyAPM Config
# ServiceName ## ServiceName
Service name displayed. Service name displayed.
...@@ -12,7 +12,7 @@ Sample Configuration Section ...@@ -12,7 +12,7 @@ Sample Configuration Section
## Logging ## Logging
SkyWalking Logging Configuration Section SkyAPM Logging Configuration Section
1. Level, defalut:Information 1. Level, defalut:Information
2. FilePath, defalut:logs\\SkyWalking-{Date}.log 2. FilePath, defalut:logs\\SkyWalking-{Date}.log
......
# SkyWalking Config 配置说明 # SkyAPM Config 配置说明
# ServiceName ## ServiceName
服务名称 服务名称
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
## Logging ## Logging
SkyWalking日志配置节点 日志配置节点
1. Level 日志级别 1. Level 日志级别
2. FilePath 日志保存路径 2. FilePath 日志保存路径
......
...@@ -46,29 +46,16 @@ namespace SkyApm ...@@ -46,29 +46,16 @@ namespace SkyApm
foreach (var service in _services) foreach (var service in _services)
await service.StartAsync(cancellationToken); await service.StartAsync(cancellationToken);
DiagnosticListener.AllListeners.Subscribe(_observer); DiagnosticListener.AllListeners.Subscribe(_observer);
_logger.Information("Started SkyWalking .NET Core Agent."); _logger.Information("Started SkyAPM .NET Core Agent.");
} }
public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken)) public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
{ {
foreach (var service in _services) foreach (var service in _services)
await service.StopAsync(cancellationToken); await service.StopAsync(cancellationToken);
_logger.Information("Stopped SkyWalking .NET Core Agent."); _logger.Information("Stopped SkyAPM .NET Core Agent.");
// ReSharper disable once MethodSupportsCancellation // ReSharper disable once MethodSupportsCancellation
await Task.Delay(TimeSpan.FromSeconds(2)); await Task.Delay(TimeSpan.FromSeconds(2));
} }
private string Welcome()
{
var builder = new StringBuilder();
builder.AppendLine("Initializing ...");
builder.AppendLine();
builder.AppendLine("***************************************************************");
builder.AppendLine("* *");
builder.AppendLine("* Welcome to Apache SkyWalking *");
builder.AppendLine("* *");
builder.AppendLine("***************************************************************");
return builder.ToString();
}
} }
} }
\ No newline at end of file
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.CommandLineUtils;
using Newtonsoft.Json;
using SkyApm.DotNet.CLI.Utils;
using SkyApm.DotNet.CLI.Extensions;
// ReSharper disable CommentTypo
// ReSharper disable IdentifierTypo
// ReSharper disable StringLiteralTypo
namespace SkyApm.DotNet.CLI.Command
{
public class InstallCommand : IAppCommand
{
private const string git_hosting_startup = "https://github.com/SkyAPM/skywalking-netcore-hosting-startup.git";
private const string manifest_proj = "SkyWalking.Runtime.Store.csproj";
private const string invalid_node_name = "SkyWalking.Runtime.Store/1.0.0";
private readonly DirectoryProvider _directoryProvider;
private readonly ShellProcessFactory _processFactory;
private readonly PlatformInformationArbiter _platformInformation;
public InstallCommand(DirectoryProvider directoryProvider, ShellProcessFactory processFactory, PlatformInformationArbiter platformInformation)
{
_directoryProvider = directoryProvider;
_processFactory = processFactory;
_platformInformation = platformInformation;
}
public string Name { get; } = "install";
public void Execute(CommandLineApplication command)
{
command.Description = "Install SkyWalking .NET Core Agent";
command.HelpOption();
var upgradeOption = command.Option("-u|--upgrade", "Upgrade SkyWalking .NET Core Agent", CommandOptionType.NoValue);
command.OnExecute(() =>
{
ConsoleUtils.WriteWelcome();
Console.WriteLine(upgradeOption.HasValue() ? "Upgrading SkyWalking .NET Core Agent ..." : "Installing SkyWalking .NET Core Agent ...");
Console.WriteLine();
var workDir = Path.Combine(_directoryProvider.TmpDirectory, _directoryProvider.AgentPath);
var workDirInfo = new DirectoryInfo(workDir);
if (workDirInfo.Exists)
workDirInfo.Delete(true);
workDirInfo.Create();
Console.WriteLine("Create tmp directory '{0}'", workDir);
var hostingStartupDir = Path.Combine(workDir, "repo");
var shell = _processFactory.Create(Shell);
shell.Exec($"git clone {git_hosting_startup} {hostingStartupDir}");
shell.Exec($"cd {Path.Combine(hostingStartupDir, "manifest")}");
shell.Exec("dotnet build --configuration Release --verbosity q -nowarn:NU1701");
shell.Exec($"dotnet store --manifest {manifest_proj} --framework netcoreapp2.1 --output {_directoryProvider.StoreDirectory} --runtime {Runtime} --skip-symbols --verbosity q -nowarn:NU1701");
var code = _processFactory.Release(shell);
if (code != 0)
{
return code;
}
//add dotnet additonalDeps
var additonalDepsPath = _directoryProvider.GetAdditonalDepsPath(_directoryProvider.AgentPath, "2.1.0");
var additonalDepsDirInfo = new DirectoryInfo(additonalDepsPath);
if (!additonalDepsDirInfo.Exists)
{
additonalDepsDirInfo.Create();
Console.WriteLine("Create dotnet additonalDeps directory '{0}'", additonalDepsPath);
}
var depsJsonFilePath = Path.Combine(hostingStartupDir, "manifest", "bin", "Release", "netcoreapp2.1", "SkyWalking.Runtime.Store.deps.json");
var depsContent = File.ReadAllText(depsJsonFilePath);
var depsObject = JsonConvert.DeserializeObject<DepsObject>(depsContent);
foreach (var target in depsObject.Targets)
target.Value?.Remove(invalid_node_name);
depsObject.Libraries.Remove(invalid_node_name);
var depsFile = new FileInfo(Path.Combine(additonalDepsPath, $"{_directoryProvider.AgentPath}.deps.json"));
using (var writer = depsFile.CreateText())
writer.Write(JsonConvert.SerializeObject(depsObject, Formatting.Indented));
Console.WriteLine("Create deps config to {0}", depsFile.FullName);
_platformInformation.Invoke(rmWorkDir_Win, rmWorkDir, rmWorkDir, rmWorkDir);
Console.WriteLine("Clean tmp directory '{0}'", workDir);
Console.WriteLine();
Console.WriteLine("SkyWalking .NET Core Agent was successfully installed.");
return 0;
void rmWorkDir_Win()
{
var cmd = _processFactory.Create("cmd.exe");
cmd.Exec($"rmdir /s/q {workDir}");
_processFactory.Release(cmd);
}
void rmWorkDir() => workDirInfo.Delete(true);
});
}
private string Shell => _platformInformation.GetValue(() => "cmd.exe", () => "sh", () => "bash", () => "sh");
private string Runtime => _platformInformation.GetValue(() => "win-x64", () => "linux-x64", () => "osx-x64", () => "linux-x64");
}
public class DepsObject
{
[JsonProperty(PropertyName = "runtimeTarget")]
public dynamic RuntimeTarget { get; set; }
[JsonProperty(PropertyName = "compilationOptions")]
public dynamic CompilationOptions { get; set; }
[JsonProperty(PropertyName = "targets")]
public Dictionary<string, Dictionary<string, dynamic>> Targets { get; set; } = new Dictionary<string, Dictionary<string, dynamic>>();
[JsonProperty(PropertyName = "libraries")]
public Dictionary<string, dynamic> Libraries { get; set; } = new Dictionary<string, dynamic>();
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
......
...@@ -40,7 +40,7 @@ namespace SkyApm.DotNet.CLI.Utils ...@@ -40,7 +40,7 @@ namespace SkyApm.DotNet.CLI.Utils
() => Path.Combine("/usr/local/share", "dotnet"), () => Path.Combine("/usr/local/share", "dotnet"),
() => Path.Combine("/usr/local/share", "dotnet")); () => Path.Combine("/usr/local/share", "dotnet"));
public string AgentPath => "skywalking.agent.aspnetcore"; public string AgentPath => "skyapm.agent.aspnetcore";
public string AdditonalDepsRootDirectory => Path.Combine(DotnetDirectory, "x64", "additionalDeps"); public string AdditonalDepsRootDirectory => Path.Combine(DotnetDirectory, "x64", "additionalDeps");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册