...
 
Commits (2)
    https://gitcode.net/lwplvx/aurora/-/commit/230bd6ee611280b90cdf02771576a769164e4ae6 重命名 httpreports项目,增加run.py脚本 2021-07-07T18:15:11+08:00 lwplvx lwplvx@yeah.net https://gitcode.net/lwplvx/aurora/-/commit/80b38899d04fcb2063156ff5c1772ede5d5d4c36 启动参数 增加环境变量 2021-07-07T18:34:15+08:00 lwplvx lwplvx@yeah.net
......@@ -22,7 +22,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "http://localhost:7000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -22,7 +22,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:6000",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Aurora.HttpRepots
namespace Aurora.HttpReports
{
public class Program
{
......
......@@ -15,11 +15,11 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Aurora.HttpRepots": {
"Aurora.HttpReports": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "http://localhost:7000",
"applicationUrl": "http://localhost:9100",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Aurora.HttpRepots
namespace Aurora.HttpReports
{
public class Startup
{
......
......@@ -22,7 +22,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"applicationUrl": "http://localhost:8000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -7,8 +7,8 @@
}
},
"Service": {
"Name": "Aurora.Core.ClientService",
"Port": "5000"
"Name": "Aurora.Core.Api",
"Port": "8000"
},
"Consul": {
"IP": "localhost",
......@@ -31,11 +31,11 @@
},
"HttpReports": {
"Transport": {
"CollectorAddress": "http://localhost:7000/",
"CollectorAddress": "http://localhost:9100/",
"DeferSecond": 10,
"DeferThreshold": 100
},
"Server": "http://localhost:5000",
"Server": "http://localhost:8000",
"Service": "User",
"Switch": true,
"RequestFilter": [ "/api/health/*", "/HttpReports*" ],
......
......@@ -22,7 +22,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"applicationUrl": "http://localhost:6000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
......@@ -21,7 +21,7 @@
"dotnetRunMessages": "true",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5001",
"applicationUrl": "http://localhost:9000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
......
import os
import signal
import subprocess
work_space = 'E:\\Workspace\\aurora'
pid_output = 'p_output'
print('work_space: ' + work_space)
print('开始运行……')
def kill_process(name):
try:
# iterating through each instance of the process
for line in os.popen("ps ax | grep " + name + " | grep -v grep"):
fields = line.split()
# extracting Process ID from the output
pid = fields[0]
# terminating process
os.kill(int(pid), signal.SIGKILL)
print("Process {} Successfully terminated".format(name))
except:
print("Error Encountered while running script")
def clear_poutput(name): # 定义函数名
b = os.getcwd()
filePath = os.path.join(b, name) # 在当前py文件所在路径下的new文件中创建txt
with open(filePath, 'a+', encoding='utf-8') as f:
f.truncate(0)
def poutput(name, pid): # 定义函数名
b = os.getcwd()
filePath = os.path.join(b, name) # 在当前py文件所在路径下的new文件中创建txt
with open(filePath, 'a+') as f:
f.write(pid+'\n') # 加\n换行显示
# dotnet Aurora.Gateway.dll --urls "http://*:6002"
# dotnet build E:\Workspace\aurora\Aurora.Gateway\Aurora.Gateway.csproj ;cd E:\Workspace\aurora\Aurora.Gateway\bin\Debug\net5.0;dotnet Aurora.Gateway.dll
def start_dotnetservice(name, runPath, port):
print('启动 ' + name)
projectPath = os.path.join(runPath, name)
dllPath = os.path.join(projectPath, r'bin\Debug\net5.0')
subprocess.run('dotnet build', shell=True, cwd=projectPath)
ret = subprocess.Popen('dotnet {}.dll --urls "http://*:{}"'.format(name,
port), shell=True, cwd=dllPath)
poutput(pid_output, "service {},pid {}".format(name, str(ret.pid)))
def start_service(name, cmd):
print('启动 ' + name)
print('run cmd -> ' + cmd)
# ret = subprocess.Popen(cmd)
ret = subprocess.Popen(cmd, shell=True)
# 记录下 pid
poutput(pid_output, "service {},pid {}".format(name, str(ret.pid)))
clear_poutput(pid_output)
print('启动 Consul')
start_service('Consul', 'consul agent -dev')
# cmd 查看端口占用 netstat -aon|findstr "8500"
# cmd 杀死进程 taskkill /f /pid 18xx8
# Gateway
s_name = 'Aurora.Gateway'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 5000)
# Tenant
s_name = 'Aurora.Tenant.Api'
runPath = os.path.join(work_space, 'Aurora.Microservices',
'Aurora.Tenant')
start_dotnetservice(s_name, runPath, 6000)
# Auth
s_name = 'Aurora.Auth'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 7000)
# Core.Api
s_name = 'Aurora.Core.Api'
runPath = os.path.join(work_space, 'Aurora.Microservices',
'Aurora.Core')
start_dotnetservice(s_name, runPath, 8000)
# WebHost
s_name = 'Aurora.WebHost'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 9000)
# HttpReports
s_name = 'Aurora.HttpReports'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 9100)
iStr = input('输入任意字符以结束……')
......@@ -39,20 +39,14 @@ def poutput(name, pid): # 定义函数名
# dotnet Aurora.Gateway.dll --urls "http://*:6002"
# dotnet build E:\Workspace\aurora\Aurora.Gateway\Aurora.Gateway.csproj ;cd E:\Workspace\aurora\Aurora.Gateway\bin\Debug\net5.0;dotnet Aurora.Gateway.dll
def start_dotnetservice(name, runPath, port):
def start_dotnetservice(name, runPath, port,env='Development'):
print('启动 ' + name)
projectPath = os.path.join(runPath, name)
dllPath = os.path.join(projectPath, r'bin\Debug\net5.0')
subprocess.run('dotnet build', shell=True, cwd=projectPath)
subprocess.Popen('dotnet {}.dll --urls "http://*:{}"'.format(name,
port), shell=True, cwd=dllPath)
# start_service(
# name, 'dotnet build {}; dotnet {}.dll'.format(projectPath, dllPath))
# start_service(
# name, 'cd {0}; dotnet build; cd {1}; dotnet {2}.dll'.format(projectPath, dllPath, name))
# start_service(
# name, 'cd {};dotnet publish -o bin/Publish;cd bin/Publish;run {}.dll'.format(runPath, name))
# subprocess.run('dotnet build', shell=True, cwd=projectPath)
ret = subprocess.Popen('dotnet {}.dll --urls "http://*:{}" --environment {} '.format(name,
port,env), shell=True, cwd=dllPath)
poutput(pid_output, "service {},pid {}".format(name, str(ret.pid)))
def start_service(name, cmd):
......@@ -67,13 +61,18 @@ def start_service(name, cmd):
clear_poutput(pid_output)
print('启动 Consul')
# start_service('Consul', 'consul agent -dev')
# d = os.system('consul agent -dev')
# d = os.popen('consul agent -dev')
start_service('Consul', 'consul agent -dev')
# cmd 查看端口占用 netstat -aon|findstr "8500"
# cmd 杀死进程 taskkill /f /pid 18xx8
# dotnet run --launch-profile "SampleApp"
# 设置环境变量 Windows 命令行:
# setx ASPNETCORE_ENVIRONMENT "Development"
# 设置环境变量 PowerShell命令:
# $Env:ASPNETCORE_ENVIRONMENT = "Development"
# MacOS/Linux
# export ASPNETCORE_ENVIRONMENT=development
# Gateway
s_name = 'Aurora.Gateway'
......@@ -102,4 +101,9 @@ s_name = 'Aurora.WebHost'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 9000)
# HttpReports
s_name = 'Aurora.HttpReports'
runPath = os.path.join(work_space)
start_dotnetservice(s_name, runPath, 9100)
iStr = input('输入任意字符以结束……')
......@@ -8,3 +8,7 @@
* [.NET Core微服务之基于Consul实现服务治理](https://www.cnblogs.com/edisonchou/p/9124985.html)
* [8分钟学会Consul集群搭建及微服务概念](https://www.cnblogs.com/ZaraNet/p/10123291.html)
* [httpreports 文档](https://www.yuque.com/httpreports/docs/azyxwc#KHHIP)
自己写的 k8s 集群搭建方法放出来
搜索一个 Docker Desktop 安装k8s的方法