From fd89f33aec3e71ca2d1f8e9efb9cd8240f576189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=9B=B7?= <284428564@QQ.com> Date: Tue, 21 May 2024 10:36:23 +0800 Subject: [PATCH] first commit --- .dockerignore | 30 ++ .gitignore | 340 ++++++++++++++++++ TelpoPush.Position.Worker/Dockerfile | 33 ++ TelpoPush.Position.Worker/Program.cs | 98 +++++ .../Properties/launchSettings.json | 15 + .../TelpoPush.Position.Worker.csproj | 26 ++ TelpoPush.Position.Worker/Worker.cs | 24 ++ .../appsettings.Development.json | 40 +++ TelpoPush.Position.Worker/appsettings.json | 77 ++++ .../appsettings.production.json | 36 ++ .../appsettings.test.json | 39 ++ TelpoPushPosition.sln | 25 ++ nuget.config | 7 + setup_production.sh | 18 + setup_test.sh | 17 + telpo_push_position_run.sh | 27 ++ 16 files changed, 852 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 TelpoPush.Position.Worker/Dockerfile create mode 100644 TelpoPush.Position.Worker/Program.cs create mode 100644 TelpoPush.Position.Worker/Properties/launchSettings.json create mode 100644 TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj create mode 100644 TelpoPush.Position.Worker/Worker.cs create mode 100644 TelpoPush.Position.Worker/appsettings.Development.json create mode 100644 TelpoPush.Position.Worker/appsettings.json create mode 100644 TelpoPush.Position.Worker/appsettings.production.json create mode 100644 TelpoPush.Position.Worker/appsettings.test.json create mode 100644 TelpoPushPosition.sln create mode 100644 nuget.config create mode 100644 setup_production.sh create mode 100644 setup_test.sh create mode 100644 telpo_push_position_run.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file diff --git a/TelpoPush.Position.Worker/Dockerfile b/TelpoPush.Position.Worker/Dockerfile new file mode 100644 index 0000000..30e1721 --- /dev/null +++ b/TelpoPush.Position.Worker/Dockerfile @@ -0,0 +1,33 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build +WORKDIR /src +COPY ["TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj", "TelpoPush.Position.Worker/"] + + +COPY ["nuget.config","."] +RUN dotnet nuget remove source nuget.org +RUN dotnet nuget add source https://repo.huaweicloud.com/repository/nuget/v3/index.json -n huaweicloud_nuget +RUN dotnet restore "TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj" +COPY . . +WORKDIR "/src/TelpoPush.Position.Worker" + + +FROM build AS publish +RUN dotnet publish "TelpoPush.Position.Worker.csproj" -c Release -o /app/publish + + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +#COPY pem /app/pem +ENV environment=Development +RUN apk add --no-cache tzdata +ENV TimeZone=Asia/Shanghai +ENV LANG C.UTF-8 +ENV ASPNETCORE_ENVIRONMENT_LOG=Development +RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone +ENTRYPOINT dotnet TelpoPush.Position.Worker.dll --environment=$environment \ No newline at end of file diff --git a/TelpoPush.Position.Worker/Program.cs b/TelpoPush.Position.Worker/Program.cs new file mode 100644 index 0000000..a33bec4 --- /dev/null +++ b/TelpoPush.Position.Worker/Program.cs @@ -0,0 +1,98 @@ +using Dapper; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Serilog; +using TelpoDataService.Util.Clients; +using TelpoPush.Position.Worker; + + +#region 日志 +//using Serilog.Events; +//using Serilog; +//using Microsoft.AspNetCore.Builder; + +//Log.Logger = new LoggerConfiguration() +//#if DEBUG +// .MinimumLevel.Debug() +//#else +// .MinimumLevel.Information() +//#endif +// .MinimumLevel.Override("Microsoft", LogEventLevel.Information) +// .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) +// .Enrich.FromLogContext() +// //.Filter.ByExcluding(c => c.Properties.Any(p => p.Value.ToString().Contains("Microsoft")))//过滤 +// .WriteTo.Async(c => c.File("/var/telpo_pushthird_ssl2/logs/infos/info.log", +// restrictedToMinimumLevel: LogEventLevel.Information, +// rollingInterval: RollingInterval.Day,//滚动策略(天) +// //fileSizeLimitBytes: 20971520, //设置单个文件大小为3M 默认1G +// rollOnFileSizeLimit: true, //超过文件大小后创建新的 +// retainedFileCountLimit: 7,//默认31,意思就是只保留最近的31个日志文件" +// outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff}[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}" +// ) +// ) +// .WriteTo.Async(c => c.File("/var/telpo_pushthird_ssl2/logs/errors/errors.log", +// restrictedToMinimumLevel: LogEventLevel.Error, +// rollingInterval: RollingInterval.Day, +// rollOnFileSizeLimit: true, +// retainedFileCountLimit: 7, +// outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff }[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}" +// ) +// ) +// .WriteTo.Async(c => c.Console()) +// .CreateLogger(); + +//选择配置文件appsetting.json +var configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .Build(); + +Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .Enrich.WithThreadId() + .CreateLogger(); +#endregion +try +{ + Log.Information("Starting up"); + var builder = Host.CreateApplicationBuilder(args); + + var config = builder.Configuration; + //builder.Services.Configure(config.GetSection("PositionConfig")); + //builder.Services.Configure(config.GetSection("ServiceConfig")); + //builder.Services.Configure(config.GetSection("Redis")); + + JsonSerializerSettings setting = new JsonSerializerSettings(); + JsonConvert.DefaultSettings = () => + { + setting.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + setting.ContractResolver = new CamelCasePropertyNamesContractResolver(); + return setting; + }; + builder.Services.AddTelpoDataServices(opt => + { + opt.TelpoDataUrl = config["ServiceConfig:TelpoDataUrl"]; + }); + + builder.Services.AddSerilog(); + builder.Services.AddHttpClient(); + //builder.Services.AddTransient(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + //builder.Services.AddSingleton(); + builder.Services.AddHostedService(); + var host = builder.Build(); + host.Run(); +} +catch (Exception ex) +{ + Log.Fatal(ex, "Application start-up failed"); +} +finally +{ + Log.CloseAndFlush(); +} \ No newline at end of file diff --git a/TelpoPush.Position.Worker/Properties/launchSettings.json b/TelpoPush.Position.Worker/Properties/launchSettings.json new file mode 100644 index 0000000..5e994bd --- /dev/null +++ b/TelpoPush.Position.Worker/Properties/launchSettings.json @@ -0,0 +1,15 @@ +{ + "profiles": { + "TelpoPush.Position.Worker": { + "commandName": "Project", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true + }, + "Container (Dockerfile)": { + "commandName": "Docker" + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json" +} \ No newline at end of file diff --git a/TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj b/TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj new file mode 100644 index 0000000..1440c91 --- /dev/null +++ b/TelpoPush.Position.Worker/TelpoPush.Position.Worker.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + dotnet-TelpoPush.Position.Worker-211b7ba5-b122-4108-a72e-d3ee6ae6a82d + Linux + + + + + + + + + + + + + + + + + + diff --git a/TelpoPush.Position.Worker/Worker.cs b/TelpoPush.Position.Worker/Worker.cs new file mode 100644 index 0000000..42d0d80 --- /dev/null +++ b/TelpoPush.Position.Worker/Worker.cs @@ -0,0 +1,24 @@ +namespace TelpoPush.Position.Worker +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + await Task.Delay(1000, stoppingToken); + } + } + } +} diff --git a/TelpoPush.Position.Worker/appsettings.Development.json b/TelpoPush.Position.Worker/appsettings.Development.json new file mode 100644 index 0000000..91013f7 --- /dev/null +++ b/TelpoPush.Position.Worker/appsettings.Development.json @@ -0,0 +1,40 @@ +{ + "ConnectionStrings": { + "DB_Connection_String": "server=139.224.254.18;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_common_ConnString": "server=139.224.254.18;port=3305;database=telpo_common;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_Healthy_ConnString": "server=139.224.254.18;port=3305;database=telpo_healthy;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none" + + //"DB_Connection_String": "server=rm-uf6j529mu0v6g0btpco.mysql.rds.aliyuncs.com;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + //"Telpo_common_ConnString": "server=rm-uf6j529mu0v6g0btpco.mysql.rds.aliyuncs.com;port=3305;database=telpo_common;uid=linwl;pwd=linwl#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none" + }, + + "PositionConfig": { + "CoreServiceApiUrl": "http://localhost:8094/api/v1", + "GpsWebApiUrl": "http://id.ssjlai.com/webapi", + //-------铻嶆櫤鑱 + "RzlManufactorId": "2cae99d6-0475-42fe-9fa7-ca27e03077de", + "RzlPushTemperatureUrl": "http://121.40.140.74:8071/api/CollectData/TemperatureTranspond", + "RzlPushTranspondUrl": "http://121.40.140.74:8071/api/CollectData/ThirdPushTranspond", + "RzlVoiceCallback": "http://121.40.140.74/GspCardStand/api/Voice/VoiceCallback" + }, + "ServiceConfig": { + "TelpoDataUrl": "http://id.ssjlai.com/data", + "KafkaBootstrapServers": "47.116.67.214:9092", // "172.19.42.53:9092", + "KafkaTopics": [ "topic.push.position" ], + "KafkaGroupId": "telpo.position", + "CacheDurationSeconds": 1200, //20鍒嗛挓 + "CacheDurationSeconds10": 600 //10鍒嗛挓 + }, + "Redis": { + //"Server": "139.224.254.18:8090", + "Server": "47.116.142.20:8090", + "Password": "telpo#1234", + "DefaultDatabase": 7, + "Poolsize": 150, + "Preheat": 50, + "Prefix": "_Third_", + "ConnectTimeout": 5000, + "IdleTimeout": 20000 + }, + "Environment": "dev" +} \ No newline at end of file diff --git a/TelpoPush.Position.Worker/appsettings.json b/TelpoPush.Position.Worker/appsettings.json new file mode 100644 index 0000000..ab701ce --- /dev/null +++ b/TelpoPush.Position.Worker/appsettings.json @@ -0,0 +1,77 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System.Net.Http.HttpClient": "Warning" + } + }, + "Serilog": { + "Using": [ "Serilog.Sinks.File", "Serilog.Sinks.Async", "Serilog.Sinks.Console", "Serilog.Sinks.Exceptionless" ], + "MinimumLevel": { + "Default": "Verbose", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System.Net.Http.HttpClient": "Warning" + } + }, + "WriteTo:Information": { + "Name": "Async", + "Args": { + "Configure": [ + { + "Name": "File", + "Args": { + "RestrictedToMinimumLevel": "Information", + "RollingInterval": "Day", + "RollOnFileSizeLimit": "true", + "OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss }[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}", + "Path": "/var/telpo_pushposition/logs/infos/info.log", + "RetainedFileCountLimit": 7 // "--璁剧疆鏃ュ織鏂囦欢涓暟鏈澶у硷紝榛樿31锛屾剰鎬濆氨鏄彧淇濈暀鏈杩戠殑31涓棩蹇楁枃浠", "绛変簬null鏃舵案杩滀繚鐣欐枃浠": null + // "FileSizeLimitBytes": 20971520, //璁剧疆鍗曚釜鏂囦欢澶у皬涓3M 榛樿1G + // "RollOnFileSizeLimit": true //瓒呰繃鏂囦欢澶у皬鍚庡垱寤烘柊鐨 + + } + } + ] + } + }, + "WriteTo:Error": { + "Name": "Async", + "Args": { + "Configure": [ + { + "Name": "File", + "Args": { + "RestrictedToMinimumLevel": "Error", + "RollingInterval": "Day", + "RollOnFileSizeLimit": "true", + "OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss }[{Level:u3}] [Thread-{ThreadId}][{SourceContext:l}] {Message:lj}{NewLine}{Exception}", + "Path": "/var/telpo_pushposition/logs/errors/error.log", + "RetainedFileCountLimit": 7 // "--璁剧疆鏃ュ織鏂囦欢涓暟鏈澶у硷紝榛樿31锛屾剰鎬濆氨鏄彧淇濈暀鏈杩戠殑31涓棩蹇楁枃浠", "绛変簬null鏃舵案杩滀繚鐣欐枃浠": null + // "FileSizeLimitBytes": 20971520, //璁剧疆鍗曚釜鏂囦欢澶у皬涓3M 榛樿1G + // "RollOnFileSizeLimit": true //瓒呰繃鏂囦欢澶у皬鍚庡垱寤烘柊鐨 + } + } + ] + } + }, + "WriteTo:Console": { + "Name": "Console", + "Args": { + "restrictedToMinimumLevel": "Verbose", + "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss }[{Level:u3}] [Thread-{ThreadId}] [{SourceContext:l}] {Message:lj}{NewLine}{Exception}", + "theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console" + } + }, + "WriteTo:Exceptionless": { + "Name": "Exceptionless", + "Args": { + "serverUrl": "http://8.134.157.154:5000", + "apiKey": "f2I0sng4BBQS9IAsbdBK1W71oOYGPpsC66s7pzJu" + } + } + } +} \ No newline at end of file diff --git a/TelpoPush.Position.Worker/appsettings.production.json b/TelpoPush.Position.Worker/appsettings.production.json new file mode 100644 index 0000000..d13cc26 --- /dev/null +++ b/TelpoPush.Position.Worker/appsettings.production.json @@ -0,0 +1,36 @@ +{ + "ConnectionStrings": { + "DB_Connection_String": "server=rm-uf6j529mu0v6g0btp.mysql.rds.aliyuncs.com;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_common_ConnString": "server=rm-uf6j529mu0v6g0btp.mysql.rds.aliyuncs.com;port=3305;database=telpo_common;uid=linwl;pwd=linwl#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_Healthy_ConnString": "server=rm-uf6j529mu0v6g0btp.mysql.rds.aliyuncs.com;port=3305;database=telpo_healthy;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none" + }, + + "PositionConfig": { + "CoreServiceApiUrl": "http://ai.ssjlai.com/gateway/core/api/v1", + "GpsWebApiUrl": "https://ai.ssjlai.com/webapi", + //-------铻嶆櫤鑱 + "RzlManufactorId": "2cae99d6-0475-42fe-9fa7-ca27e03077de", + "RzlPushTemperatureUrl": "http://121.40.140.74:8071/api/CollectData/TemperatureTranspond", + "RzlPushTranspondUrl": "http://121.40.140.74:8071/api/CollectData/ThirdPushTranspond", + "RzlVoiceCallback": "http://121.40.140.74/GspCardStand/api/Voice/VoiceCallback" + }, + "ServiceConfig": { + "TelpoDataUrl": "https://ai.ssjlai.com/data", + "KafkaBootstrapServers": "172.19.42.40:9092,172.19.42.41:9092,172.19.42.48:9092", + "KafkaTopics": [ "topic.push.position" ], + "KafkaGroupId": "telpo.position", + "CacheDurationSeconds": 1200, //20鍒嗛挓 + "CacheDurationSeconds10": 600 //10鍒嗛挓 + }, + "Redis": { + "Server": "172.19.42.40:8090", + "Password": "telpo#1234", + "DefaultDatabase": 7, + "Poolsize": 150, + "Preheat": 50, + "Prefix": "_Third_", + "ConnectTimeout": 5000, + "IdleTimeout": 20000 + }, + "Environment": "production" +} \ No newline at end of file diff --git a/TelpoPush.Position.Worker/appsettings.test.json b/TelpoPush.Position.Worker/appsettings.test.json new file mode 100644 index 0000000..89251fb --- /dev/null +++ b/TelpoPush.Position.Worker/appsettings.test.json @@ -0,0 +1,39 @@ +{ + "ConnectionStrings": { + "DB_Connection_String": "server=139.224.254.18;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_common_ConnString": "server=139.224.254.18;port=3305;database=telpo_common;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + "Telpo_Healthy_ConnString": "server=139.224.254.18;port=3305;database=telpo_healthy;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none" + + //"DB_Connection_String": "server=rm-uf6j529mu0v6g0btpco.mysql.rds.aliyuncs.com;port=3305;database=gps_card;uid=root;pwd=telpo#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none", + //"Telpo_common_ConnString": "server=rm-uf6j529mu0v6g0btpco.mysql.rds.aliyuncs.com;port=3305;database=telpo_common;uid=linwl;pwd=linwl#1234;CharSet=utf8;MinimumPoolSize=10;MaximumPoolSize=1000;SslMode=none" + }, + + "PositionConfig": { + "CoreServiceApiUrl": "http://localhost:8094/api/v1", + "GpsWebApiUrl": "http://id.ssjlai.com/webapi", + //-------铻嶆櫤鑱 + "RzlManufactorId": "2cae99d6-0475-42fe-9fa7-ca27e03077de", + "RzlPushTemperatureUrl": "http://121.40.140.74:8071/api/CollectData/TemperatureTranspond", + "RzlPushTranspondUrl": "http://121.40.140.74:8071/api/CollectData/ThirdPushTranspond", + "RzlVoiceCallback": "http://121.40.140.74/GspCardStand/api/Voice/VoiceCallback" + }, + "ServiceConfig": { + "TelpoDataUrl": "http://id.ssjlai.com/data", + "KafkaBootstrapServers": "172.19.42.53:9092", // "172.19.42.53:9092", + "KafkaTopics": [ "topic.push.position" ], + "KafkaGroupId": "telpo.position", + "CacheDurationSeconds": 1200, //20鍒嗛挓 + "CacheDurationSeconds10": 600 //10鍒嗛挓 + }, + "Redis": { + "Server": "172.19.42.44:8090", + "Password": "telpo#1234", + "DefaultDatabase": 7, + "Poolsize": 150, + "Preheat": 50, + "Prefix": "_Third_", + "ConnectTimeout": 5000, + "IdleTimeout": 20000 + }, + "Environment": "dev" +} \ No newline at end of file diff --git a/TelpoPushPosition.sln b/TelpoPushPosition.sln new file mode 100644 index 0000000..4d06302 --- /dev/null +++ b/TelpoPushPosition.sln @@ -0,0 +1,25 @@ +锘 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34723.18 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TelpoPush.Position.Worker", "TelpoPush.Position.Worker\TelpoPush.Position.Worker.csproj", "{7E015BBC-126F-40AA-B261-0C58ED0FE0DE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7E015BBC-126F-40AA-B261-0C58ED0FE0DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E015BBC-126F-40AA-B261-0C58ED0FE0DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E015BBC-126F-40AA-B261-0C58ED0FE0DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E015BBC-126F-40AA-B261-0C58ED0FE0DE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {76B08062-E22A-4D9C-A1BB-6D713A3A5DEE} + EndGlobalSection +EndGlobal diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..365f5c7 --- /dev/null +++ b/nuget.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/setup_production.sh b/setup_production.sh new file mode 100644 index 0000000..119e791 --- /dev/null +++ b/setup_production.sh @@ -0,0 +1,18 @@ +锘#!/usr/bin/env bash +image_version=$version +# 鍒犻櫎闀滃儚 +docker rmi -f $( + docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_position | awk '{print $3}' +) +# 鏋勫缓telpo/mrp:$image_version闀滃儚 +docker build -f ./TelpoPush.Position.Worker/Dockerfile . -t telpo/telpo_push_position:$image_version +#TODO:鎺ㄩ侀暅鍍忓埌闃块噷浠撳簱 +echo '=================寮濮嬫帹閫侀暅鍍=======================' +docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com +docker tag telpo/telpo_push_position:$image_version registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_position:$image_version +docker push registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_position:$image_version +echo '=================鎺ㄩ侀暅鍍忓畬鎴=======================' +#鍒犻櫎浜х敓鐨凬one闀滃儚 +docker rmi -f $(docker images | grep none | awk '{print $3}') +# 鏌ョ湅闀滃儚鍒楄〃 +docker images diff --git a/setup_test.sh b/setup_test.sh new file mode 100644 index 0000000..59303f7 --- /dev/null +++ b/setup_test.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +image_version=$version +# 鍒犻櫎闀滃儚 +docker rmi -f $( + docker images | grep 139.224.254.18:5000/telpo_push_position | awk '{print $3}' +) +# 鏋勫缓telpo/mrp:$image_version闀滃儚 +docker build -f ./TelpoPush.Position.Worker/Dockerfile . -t telpo/telpo_push_position:$image_version +#TODO:鎺ㄩ侀暅鍍忓埌绉佹湁浠撳簱 +echo '=================寮濮嬫帹閫侀暅鍍=======================' +docker tag telpo/telpo_push_position:$image_version 139.224.254.18:5000/telpo_push_position:$image_version +docker push 139.224.254.18:5000/telpo_push_position:$image_version +echo '=================鎺ㄩ侀暅鍍忓畬鎴=======================' +#鍒犻櫎浜х敓鐨凬one闀滃儚 +docker rmi -f $(docker images | grep none | awk '{print $3}') +# 鏌ョ湅闀滃儚鍒楄〃 +docker images \ No newline at end of file diff --git a/telpo_push_position_run.sh b/telpo_push_position_run.sh new file mode 100644 index 0000000..0eb60d4 --- /dev/null +++ b/telpo_push_position_run.sh @@ -0,0 +1,27 @@ +#!/bin/bash +environment=$1 +version=$2 +echo "鐜鍙橀噺涓${environment},鐗堟湰涓$version!" +if [[ ${environment} == 'production' ]]; then + echo "寮濮嬭繙绋嬫瀯寤哄鍣" + docker stop telpo_push_third_ssl || true + docker rm telpo_push_third_ssl || true + docker rmi -f $(docker images | grep registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_third_ssl | awk '{print $3}') + docker login --username=rzl_wangjx@1111649216405698 --password=telpo.123 registry.cn-shanghai.aliyuncs.com + docker pull registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_third_ssl:$version + docker run -d --network=host -e environment=production -v /home/data/telpo_push_third_ssl/log:/var/telpo_pushthird_ssl/logs --restart=always --name telpo_push_third_ssl registry.cn-shanghai.aliyuncs.com/gps_card/telpo_push_third_ssl:$version; + #鍒犻櫎浜х敓鐨凬one闀滃儚 + docker rmi -f $(docker images | grep none | awk '{print $3}') + docker ps -a + +elif [[ ${environment} == 'test' ]]; then + echo "寮濮嬪湪娴嬭瘯鐜杩滅▼鏋勫缓瀹瑰櫒" + docker stop telpo_push_third_ssl || true + docker rm telpo_push_third_ssl || true + docker rmi -f $(docker images | grep 139.224.254.18:5000/telpo_push_third_ssl | awk '{print $3}') + docker pull 139.224.254.18:5000/telpo_push_third_ssl:$version + docker run -d --network=host -e environment=${environment} -v /home/data/telpo_push_third_ssl/log:/var/telpo_pushthird_ssl/logs --restart=always --name telpo_push_third_ssl 139.224.254.18:5000/telpo_push_third_ssl:$version; + #鍒犻櫎浜х敓鐨凬one闀滃儚 + docker rmi -f $(docker images | grep none | awk '{print $3}') + docker ps -a +fi \ No newline at end of file