From f00a3e10060fbd47385d0c4d99aca384a66ecbaf Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Mon, 18 May 2020 17:17:47 +0800 Subject: [PATCH] update Former-commit-id: 8ac42810283b761e55e05fcacc001220a3bfd484 --- docs/temp/ubuntu开机启动.txt | 21 ++++ labs/docker/docker-compose.override.yml | 3 + labs/docker/docker-compose.yml | 14 +-- labs/docker/nginx/conf/nginx.conf | 15 ++- labs/docker/temp.txt | 14 +++ .../Controllers/MessageController.cs | 64 ---------- projects/UserCenter/Startup.cs | 21 +--- projects/UserCenter/UserCenter.csproj | 1 - tools/nginx-1.18.0/conf/nginx.conf | 13 +- tools/nginx-1.18.0/conf/nginx.conf.bk | 117 ------------------ 10 files changed, 56 insertions(+), 227 deletions(-) create mode 100644 docs/temp/ubuntu开机启动.txt create mode 100644 labs/docker/docker-compose.override.yml create mode 100644 labs/docker/temp.txt delete mode 100644 projects/UserCenter/Controllers/MessageController.cs delete mode 100644 tools/nginx-1.18.0/conf/nginx.conf.bk diff --git a/docs/temp/ubuntu开机启动.txt b/docs/temp/ubuntu开机启动.txt new file mode 100644 index 00000000..221aec60 --- /dev/null +++ b/docs/temp/ubuntu开机启动.txt @@ -0,0 +1,21 @@ +1.nano /etc/rc.local + +#https://linuxize.com/post/how-to-install-and-use-docker-compose-on-ubuntu-18-04/ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +#echo `date +"%Y-%m-%d %H:%M:%S"` > /root/start.log + +exit 0 + +2.chmod +x /etc/rc.local \ No newline at end of file diff --git a/labs/docker/docker-compose.override.yml b/labs/docker/docker-compose.override.yml new file mode 100644 index 00000000..0ed2a44d --- /dev/null +++ b/labs/docker/docker-compose.override.yml @@ -0,0 +1,3 @@ +#this file contains services override for development only +#docker-compose up +version: "3.8" \ No newline at end of file diff --git a/labs/docker/docker-compose.yml b/labs/docker/docker-compose.yml index b1cd6b23..384b0786 100644 --- a/labs/docker/docker-compose.yml +++ b/labs/docker/docker-compose.yml @@ -1,3 +1,5 @@ +#this file contains the shard service for both development and production services +#nginx mysql srs influxdb #https://docs.docker.com/compose/compose-file/ version: "3.8" @@ -10,14 +12,4 @@ services: - ./nginx/conf/edusoa.key:/etc/nginx/edusoa.key - ./nginx/conf/edusoa.pem:/etc/nginx/edusoa.pem - ./nginx/log:/var/log/nginx - ports: - - 80:80 - - 443:443 - networks: - default: - ipv4_address: 172.16.0.10 -networks: - default: - ipam: - config: - - subnet: 172.16.0.0/16 \ No newline at end of file + network_mode: "host" \ No newline at end of file diff --git a/labs/docker/nginx/conf/nginx.conf b/labs/docker/nginx/conf/nginx.conf index 6a8b05f3..260cdf4a 100644 --- a/labs/docker/nginx/conf/nginx.conf +++ b/labs/docker/nginx/conf/nginx.conf @@ -12,14 +12,13 @@ events { worker_connections 1024; } - http { include mime.types; default_type application/octet-stream; types { application/vnd.android.package-archive apk; application/iphone pxl ipa; - text/plain plist; + text/plain plist; } sendfile on; @@ -27,16 +26,16 @@ http { keepalive_timeout 65; upstream go-fastdfs { - server 10.10.24.104:8180; - ip_hash; - } - + server 10.10.24.104:8180; + ip_hash; + } + server { listen 80; listen 443 ssl; server_name iot.edusoa.com; - - #ssl on; + + #ssl on; ssl_certificate edusoa.pem; ssl_certificate_key edusoa.key; ssl_session_timeout 5m; diff --git a/labs/docker/temp.txt b/labs/docker/temp.txt new file mode 100644 index 00000000..13a2a30c --- /dev/null +++ b/labs/docker/temp.txt @@ -0,0 +1,14 @@ + usercenter: + image: mcr.microsoft.com/dotnet/core/runtime-deps:3.1-focal + volumes: + - ./UserCenter:/UserCenter + ports: + - 8010:8010 + command: bash -c " + chmod +x /UserCenter/UserCenter + && cd /UserCenter + && ./UserCenter + " + networks: + default: + ipv4_address: 172.16.0.11 \ No newline at end of file diff --git a/projects/UserCenter/Controllers/MessageController.cs b/projects/UserCenter/Controllers/MessageController.cs deleted file mode 100644 index f2a27310..00000000 --- a/projects/UserCenter/Controllers/MessageController.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Application.Models; -using Infrastructure.Extensions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.SignalR; -using Raven.Embedded; -using System; -using System.Linq; -using UserCenter.Services; - -namespace UserCenter.Controllers -{ - public class MessageController : Controller - { - private readonly IHubContext _pageHubContext; - - public MessageController(IHubContext pageHubContext) - { - this._pageHubContext = pageHubContext; - } - - public IActionResult SendMessage(string content = "窗前明月光,疑是地上霜") - { - var message = new Message - { - Id = Guid.NewGuid().ToString(), - Type = "通知", - FromId = "admin", - FromName = "管理员", - ToId = "iot", - ToName = "智慧教室", - Content = content + DateTime.Now.Ticks, - Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds() - }; - using (var store = EmbeddedServer.Instance.GetDocumentStore("Embedded")) - { - using (var session = store.OpenSession()) - { - session.Store(message); - session.SaveChanges(); - if (message.Type == "通知") - { - this._pageHubContext.Clients.All.SendAsync("receive", message); - } - } - } - return Json(message); - } - - public IActionResult GetMessage(string toId, int pageIndex = 0, int pageSize = 20) - { - using (var store = EmbeddedServer.Instance.GetDocumentStore("Embedded")) - { - using (var session = store.OpenSession()) - { - var list = session.Query() - .Where(o => o.Type == "通知" && o.ToId == toId) - .OrderByDescending(o => o.Timestamp) - .Paged(pageIndex, pageSize); - return Json(list); - } - } - } - } -} \ No newline at end of file diff --git a/projects/UserCenter/Startup.cs b/projects/UserCenter/Startup.cs index 2cf7e690..193a87dd 100644 --- a/projects/UserCenter/Startup.cs +++ b/projects/UserCenter/Startup.cs @@ -2,13 +2,9 @@ using Infrastructure.Data; using Infrastructure.Email; using Infrastructure.Sms; using Infrastructure.Web; -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Raven.Embedded; -using System; namespace UserCenter { @@ -16,7 +12,6 @@ namespace UserCenter { public Startup(IConfiguration configuration, IWebHostEnvironment env) : base(configuration, env) { - EmbeddedServer.Instance.StartServer(); } public override void ConfigureServices(IServiceCollection services) @@ -24,23 +19,9 @@ namespace UserCenter services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); //services.AddSingleton(); base.ConfigureServices(services); } - - public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - base.Configure(app, env, loggerFactory); - //app.ApplicationServices.GetRequiredService(); - } - - public override void CreateDatabase(IServiceProvider services) - { - //if (this.env.IsDevelopment()) - { - base.CreateDatabase(services); - } - } } } \ No newline at end of file diff --git a/projects/UserCenter/UserCenter.csproj b/projects/UserCenter/UserCenter.csproj index 7dc617ae..75bd5fef 100644 --- a/projects/UserCenter/UserCenter.csproj +++ b/projects/UserCenter/UserCenter.csproj @@ -14,7 +14,6 @@ - diff --git a/tools/nginx-1.18.0/conf/nginx.conf b/tools/nginx-1.18.0/conf/nginx.conf index 661e17db..cd507dbf 100644 --- a/tools/nginx-1.18.0/conf/nginx.conf +++ b/tools/nginx-1.18.0/conf/nginx.conf @@ -12,7 +12,6 @@ events { worker_connections 1024; } - http { include mime.types; default_type application/octet-stream; @@ -26,10 +25,10 @@ http { keepalive_timeout 65; - upstream go-fastdfs { - server 10.10.24.104:8180; - ip_hash; - } + upstream go-fastdfs { + server 10.10.24.104:8180; + ip_hash; + } server { listen 80; @@ -45,6 +44,8 @@ http { ssl_ciphers HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM; ssl_prefer_server_ciphers on; + set $ip 'localhost'; + location / { #proxy_set_header Host $host:$server_port; if ($http_user_agent ~* "(mobile|android|ipad|iphone|ipod|tablet)") { @@ -70,7 +71,7 @@ http { } location ^~ /UserCenter/ { - proxy_pass http://localhost:8010/UserCenter/; + proxy_pass http://[$ip]:8010/UserCenter/; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; diff --git a/tools/nginx-1.18.0/conf/nginx.conf.bk b/tools/nginx-1.18.0/conf/nginx.conf.bk deleted file mode 100644 index 29bc085f..00000000 --- a/tools/nginx-1.18.0/conf/nginx.conf.bk +++ /dev/null @@ -1,117 +0,0 @@ - -#user nobody; -worker_processes 1; - -#error_log logs/error.log; -#error_log logs/error.log notice; -#error_log logs/error.log info; - -#pid logs/nginx.pid; - - -events { - worker_connections 1024; -} - - -http { - include mime.types; - default_type application/octet-stream; - - #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - # '$status $body_bytes_sent "$http_referer" ' - # '"$http_user_agent" "$http_x_forwarded_for"'; - - #access_log logs/access.log main; - - sendfile on; - #tcp_nopush on; - - #keepalive_timeout 0; - keepalive_timeout 65; - - #gzip on; - - server { - listen 80; - server_name localhost; - - #charset koi8-r; - - #access_log logs/host.access.log main; - - location / { - root html; - index index.html index.htm; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} - - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} - } - - - # another virtual host using mix of IP-, name-, and port-based configuration - # - #server { - # listen 8000; - # listen somename:8080; - # server_name somename alias another.alias; - - # location / { - # root html; - # index index.html index.htm; - # } - #} - - - # HTTPS server - # - #server { - # listen 443 ssl; - # server_name localhost; - - # ssl_certificate cert.pem; - # ssl_certificate_key cert.key; - - # ssl_session_cache shared:SSL:1m; - # ssl_session_timeout 5m; - - # ssl_ciphers HIGH:!aNULL:!MD5; - # ssl_prefer_server_ciphers on; - - # location / { - # root html; - # index index.html index.htm; - # } - #} - -}