Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
f39f31c2
IoTSharp
项目概览
IoTSharp
/
IoTSharp
大约 1 年 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f39f31c2
编写于
10月 31, 2020
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加RabbitMQ调整url连接字符串的问题 调整docker-compose 相关问题
上级
b0808ead
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
113 addition
and
75 deletion
+113
-75
.gitignore
.gitignore
+3
-0
IoTSharp/Extensions/IoTSharpExtension.cs
IoTSharp/Extensions/IoTSharpExtension.cs
+41
-1
IoTSharp/Startup.cs
IoTSharp/Startup.cs
+20
-15
IoTSharp/appsettings.Development.json
IoTSharp/appsettings.Development.json
+7
-25
IoTSharp/appsettings.json
IoTSharp/appsettings.json
+4
-10
appsettings.Development.json
appsettings.Development.json
+6
-19
docker-compose.override.yml
docker-compose.override.yml
+0
-1
docker-compose.yml
docker-compose.yml
+32
-4
未找到文件。
.gitignore
浏览文件 @
f39f31c2
...
@@ -339,3 +339,6 @@ ASALocalRun/
...
@@ -339,3 +339,6 @@ ASALocalRun/
/IoTSharp/DiskQuue-log.iotsharp
/IoTSharp/DiskQuue-log.iotsharp
/zk-single-kafka-single
/zk-single-kafka-single
/postgresql
/postgresql
/data
/data
/rabbitmq
IoTSharp/Extensions/IoTSharpExtension.cs
浏览文件 @
f39f31c2
using
IoTSharp.Data
;
using
DotNetCore.CAP
;
using
IoTSharp.Data
;
using
IoTSharp.Services
;
using
IoTSharp.Services
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
...
@@ -9,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -9,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
MQTTnet.Diagnostics
;
using
MQTTnet.Diagnostics
;
using
Silkier.Extensions
;
using
System
;
using
System
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
...
@@ -97,5 +99,43 @@ namespace IoTSharp
...
@@ -97,5 +99,43 @@ namespace IoTSharp
return
externalPath
+
internalUiRoute
;
return
externalPath
+
internalUiRoute
;
});
});
}
}
public
static
CapOptions
UseRabbitMQ
(
this
CapOptions
options
,
Uri
url
)
{
return
options
.
UseRabbitMQ
(
opt
=>
{
var
usr
=
url
.
UserInfo
?.
Split
(
':'
);
opt
.
HostName
=
url
.
Host
;
opt
.
UserName
=
usr
?.
Length
>
0
?
usr
[
0
]
:
RabbitMQOptions
.
DefaultUser
;
opt
.
Password
=
usr
?.
Length
>
1
?
usr
[
1
]
:
RabbitMQOptions
.
DefaultPass
;
opt
.
Port
=
url
.
Port
;
});
}
public
static
void
ConnectionString2Options
<
T
>(
this
T
option
,
string
_connectionString
)
{
_connectionString
.
Split
(
';'
,
StringSplitOptions
.
RemoveEmptyEntries
).
ForEach
(
f
=>
{
try
{
var
opt
=
f
.
Split
(
'='
);
var
pty
=
option
?.
GetType
().
GetProperty
(
opt
[
0
]);
if
(
pty
.
PropertyType
==
typeof
(
string
))
{
pty
.
SetValue
(
option
,
opt
[
1
]);
}
else
if
(
pty
.
PropertyType
==
typeof
(
int
))
{
pty
.
SetValue
(
option
,
int
.
Parse
(
opt
[
1
]));
}
else
if
(
pty
.
PropertyType
==
typeof
(
bool
))
{
pty
.
SetValue
(
option
,
opt
[
1
]?.
ToString
().
ToLower
()
==
bool
.
TrueString
.
ToLower
());
}
}
catch
(
Exception
)
{
}
});
}
}
}
}
}
\ No newline at end of file
IoTSharp/Startup.cs
浏览文件 @
f39f31c2
...
@@ -49,6 +49,8 @@ using EasyCaching.Core.Configurations;
...
@@ -49,6 +49,8 @@ using EasyCaching.Core.Configurations;
using
Silkier.Extensions
;
using
Silkier.Extensions
;
using
Maikebing.Data.Taos
;
using
Maikebing.Data.Taos
;
using
Dynamitey
;
using
Dynamitey
;
using
DotNetCore.CAP
;
using
RabbitMQ.Client
;
namespace
IoTSharp
namespace
IoTSharp
{
{
...
@@ -138,13 +140,14 @@ namespace IoTSharp
...
@@ -138,13 +140,14 @@ namespace IoTSharp
services
.
AddMqttClient
(
settings
.
MqttClient
);
services
.
AddMqttClient
(
settings
.
MqttClient
);
services
.
AddSingleton
<
RetainedMessageHandler
>();
services
.
AddSingleton
<
RetainedMessageHandler
>();
var
healthChecks
=
services
.
AddHealthChecks
()
var
healthChecks
=
services
.
AddHealthChecks
()
.
AddNpgSql
(
Configuration
[
"IoTSharp"
]
,
name
:
"PostgreSQL"
)
.
AddNpgSql
(
Configuration
.
GetConnectionString
(
"IoTSharp"
)
,
name
:
"PostgreSQL"
)
.
AddDiskStorageHealthCheck
(
dso
=>
.
AddDiskStorageHealthCheck
(
dso
=>
{
{
System
.
IO
.
DriveInfo
.
GetDrives
().
Select
(
f
=>
f
.
Name
).
Distinct
().
ToList
().
ForEach
(
f
=>
dso
.
AddDrive
(
f
,
1024
));
System
.
IO
.
DriveInfo
.
GetDrives
().
Select
(
f
=>
f
.
Name
).
Distinct
().
ToList
().
ForEach
(
f
=>
dso
.
AddDrive
(
f
,
1024
));
},
name
:
"Disk Storage"
);
},
name
:
"Disk Storage"
);
services
.
AddHealthChecksUI
().
AddPostgreSqlStorage
(
Configuration
.
GetConnectionString
(
"IoTSharp"
));
services
.
AddHealthChecksUI
(
cfg
=>
cfg
.
AddHealthCheckEndpoint
(
"IoTSharp"
,
"http://iotsharp/healthz"
))
.
AddPostgreSqlStorage
(
Configuration
.
GetConnectionString
(
"IoTSharp"
));
services
.
AddSilkierQuartz
(
opt
=>
services
.
AddSilkierQuartz
(
opt
=>
{
{
//opt.Add("quartz.serializer.type", "json");
//opt.Add("quartz.serializer.type", "json");
...
@@ -197,8 +200,8 @@ namespace IoTSharp
...
@@ -197,8 +200,8 @@ namespace IoTSharp
break
;
break
;
case
TelemetryStorage
.
Taos
:
case
TelemetryStorage
.
Taos
:
services
.
AddSingleton
<
IStorage
,
TaosStorage
>();
services
.
AddSingleton
<
IStorage
,
TaosStorage
>();
services
.
AddObjectPool
(()=>
new
TaosConnection
(
settings
.
ConnectionStrings
[
"T
aos
"
]));
services
.
AddObjectPool
(()=>
new
TaosConnection
(
settings
.
ConnectionStrings
[
"T
elemetryStorage
"
]));
healthChecks
.
AddTDengine
(
Configuration
.
GetConnectionString
(
"T
aos
"
));
healthChecks
.
AddTDengine
(
Configuration
.
GetConnectionString
(
"T
elemetryStorage
"
));
break
;
break
;
default
:
default
:
break
;
break
;
...
@@ -232,7 +235,8 @@ namespace IoTSharp
...
@@ -232,7 +235,8 @@ namespace IoTSharp
{
{
case
EventBusMQ
.
RabbitMQ
:
case
EventBusMQ
.
RabbitMQ
:
x
.
UseRabbitMQ
(
Configuration
.
GetConnectionString
(
"EventBusMQ"
));
x
.
UseRabbitMQ
(
new
Uri
(
Configuration
.
GetConnectionString
(
"EventBusMQ"
)));
//amqp://guest:guest@localhost:5672
healthChecks
.
AddRabbitMQ
(
Configuration
.
GetConnectionString
(
"EventBusMQ"
),
name
:
"EventBusMQ"
);
healthChecks
.
AddRabbitMQ
(
Configuration
.
GetConnectionString
(
"EventBusMQ"
),
name
:
"EventBusMQ"
);
break
;
break
;
case
EventBusMQ
.
Kafka
:
case
EventBusMQ
.
Kafka
:
...
@@ -305,22 +309,23 @@ namespace IoTSharp
...
@@ -305,22 +309,23 @@ namespace IoTSharp
});
});
app
.
UseSwaggerUi3
();
app
.
UseSwaggerUi3
();
app
.
UseOpenApi
();
app
.
UseOpenApi
();
app
.
UseForwardedHeaders
(
new
ForwardedHeadersOptions
{
ForwardedHeaders
=
ForwardedHeaders
.
XForwardedFor
|
ForwardedHeaders
.
XForwardedProto
});
app
.
UseResponseCompression
();
// No need if you use IIS, but really something good for Kestrel!
app
.
UseHealthChecks
(
"/healthz"
,
new
HealthCheckOptions
app
.
UseHealthChecks
(
"/healthz"
,
new
HealthCheckOptions
{
{
Predicate
=
_
=>
true
,
Predicate
=
_
=>
true
,
ResponseWriter
=
UIResponseWriter
.
WriteHealthCheckUIResponse
ResponseWriter
=
(
httpContext
,
report
)
=>
{
return
UIResponseWriter
.
WriteHealthCheckUIResponse
(
httpContext
,
report
);
}
});
});
app
.
UseHealthChecksUI
();
app
.
UseHealthChecksUI
();
app
.
UseForwardedHeaders
(
new
ForwardedHeadersOptions
{
ForwardedHeaders
=
ForwardedHeaders
.
XForwardedFor
|
ForwardedHeaders
.
XForwardedProto
});
app
.
UseResponseCompression
();
// No need if you use IIS, but really something good for Kestrel!
}
}
}
}
}
}
\ No newline at end of file
IoTSharp/appsettings.Development.json
浏览文件 @
f39f31c2
...
@@ -7,34 +7,16 @@
...
@@ -7,34 +7,16 @@
}
}
},
},
"ConnectionStrings"
:
{
"ConnectionStrings"
:
{
"IoTSharp"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
"IoTSharp"
:
"Server=pgsql;Database=IoTSharp;Username=postgres;Password=future;"
,
"EventBusStore"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
"EventBusStore"
:
"mongodb://root:kissme@mongodb:27017"
,
"TelemetryStorage"
:
"Server=localhost;Database=IoTSharp;Username=postgres;Password=future;"
,
"TelemetryStorage"
:
"DataSource=taos;DataBase=IoTSharp;Username=root;Password=taosdata;Port=6030"
,
"EventBusMQ"
:
"127.0.0.1"
"EventBusMQ"
:
"amqp://root:kissme@rabbitmq:5672"
},
"MqttBroker"
:
{
"Port"
:
7777
},
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"PostgreSql"
,
"EventBusStore"
:
"MongoDB"
,
"EventBusMQ"
:
"ZeroMQ"
,
"EventBusMQ"
:
"RabbitMQ"
,
"TelemetryStorage"
:
"Sharding"
,
"TelemetryStorage"
:
"Taos"
"CachingUseIn"
:
"InMemory"
,
"CachingUseRedisHosts"
:
"127.0.0.1:6379;127.0.0.2:6379"
,
"Sharding"
:
{
"DatabaseType"
:
"PostgreSql"
,
"ExpandByDateMode"
:
"PerMonth"
},
"NetMQ"
:
{
"Enable"
:
"true"
,
"SubscriberAddress"
:
"tcp://127.0.0.1:5556"
,
"PublisherAddress"
:
"tcp://127.0.0.1:5557"
},
"ZMQOption"
:
{
"SendAddress"
:
"tcp://127.0.0.1:5556"
,
"ReceiveAddress"
:
"tcp://127.0.0.1:5557"
}
}
}
\ No newline at end of file
IoTSharp/appsettings.json
浏览文件 @
f39f31c2
...
@@ -12,22 +12,16 @@
...
@@ -12,22 +12,16 @@
"JwtExpireHours"
:
24
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"HealthChecks
-
UI"
:
{
"HealthChecksUI"
:
{
"HealthChecks"
:
[
"HealthChecks"
:
[
{
{
"Name"
:
"
HTTP-Api-Basic
"
,
"Name"
:
"
IoTSharp
"
,
"Uri"
:
"http://
localhost
/healthz"
"Uri"
:
"http://
iotsharp
/healthz"
}
}
],
],
"Webhooks"
:
[
"Webhooks"
:
[
{
"Name"
:
""
,
"Uri"
:
""
,
"Payload"
:
""
,
"RestoredPayload"
:
""
}
],
],
"EvaluationTime
O
nSeconds"
:
10
,
"EvaluationTime
i
nSeconds"
:
10
,
"MinimumSecondsBetweenFailureNotifications"
:
60
"MinimumSecondsBetweenFailureNotifications"
:
60
},
},
"AllowedHosts"
:
"*"
"AllowedHosts"
:
"*"
...
...
appsettings.Development.json
浏览文件 @
f39f31c2
...
@@ -8,28 +8,15 @@
...
@@ -8,28 +8,15 @@
},
},
"ConnectionStrings"
:
{
"ConnectionStrings"
:
{
"IoTSharp"
:
"Server=pgsql;Database=IoTSharp;Username=postgres;Password=future;"
,
"IoTSharp"
:
"Server=pgsql;Database=IoTSharp;Username=postgres;Password=future;"
,
"EventBusStore"
:
"
Server=pgsql;Database=IoTSharp;Username=postgres;Password=future;
"
,
"EventBusStore"
:
"
mongodb://root:kissme@mongodb:27017
"
,
"TelemetryStorage"
:
"
Server=pgsql;Database=IoTSharp;Username=postgres;Password=future;
"
,
"TelemetryStorage"
:
"
DataSource=taos;DataBase=IoTSharp;Username=root;Password=taosdata;Port=6030
"
,
"EventBusMQ"
:
"
127.0.0.1
"
"EventBusMQ"
:
"
amqp://root:kissme@rabbitmq:5672
"
},
},
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtKey"
:
"kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme"
,
"JwtExpireHours"
:
24
,
"JwtExpireHours"
:
24
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtIssuer"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"JwtAudience"
:
"IoTSharp.Net"
,
"EventBusStore"
:
"PostgreSql"
,
"EventBusStore"
:
"MongoDB"
,
"EventBusMQ"
:
"ZeroMQ"
,
"EventBusMQ"
:
"RabbitMQ"
,
"TelemetryStorage"
:
"Sharding"
,
"TelemetryStorage"
:
"Taos"
"Sharding"
:
{
"DatabaseType"
:
"PostgreSql"
,
"ExpandByDateMode"
:
"PerMonth"
},
"NetMQ"
:
{
"Enable"
:
"true"
,
"SubscriberAddress"
:
"tcp://127.0.0.1:5556"
,
"PublisherAddress"
:
"tcp://127.0.0.1:5557"
},
"ZMQOption"
:
{
"SendAddress"
:
"tcp://127.0.0.1:5556"
,
"ReceiveAddress"
:
"tcp://127.0.0.1:5557"
}
}
}
\ No newline at end of file
docker-compose.override.yml
浏览文件 @
f39f31c2
version
:
'
3.4'
version
:
'
3.4'
services
:
services
:
iotsharp
:
iotsharp
:
image
:
${DOCKER_REGISTRY-}iotsharp
image
:
${DOCKER_REGISTRY-}iotsharp
...
...
docker-compose.yml
浏览文件 @
f39f31c2
...
@@ -5,7 +5,7 @@ services:
...
@@ -5,7 +5,7 @@ services:
container_name
:
pgsql
container_name
:
pgsql
restart
:
always
restart
:
always
volumes
:
volumes
:
-
"
./postgresql:/var/lib/postgresql/data"
-
"
./
data/
postgresql:/var/lib/postgresql/data"
environment
:
environment
:
TZ
:
"
Asia/Shanghai"
TZ
:
"
Asia/Shanghai"
POSTGRES_USER
:
postgres
POSTGRES_USER
:
postgres
...
@@ -55,10 +55,38 @@ services:
...
@@ -55,10 +55,38 @@ services:
networks
:
networks
:
-
iotsharp-network
-
iotsharp-network
rabbitmq
:
image
:
rabbitmq:management
container_name
:
rabbitmq
restart
:
always
hostname
:
mq
ports
:
-
15672:15672
-
5672:5672
volumes
:
-
./data/rabbitmq:/var/lib/rabbitmq
environment
:
-
RABBITMQ_DEFAULT_USER=root
-
RABBITMQ_DEFAULT_PASS=kissme
networks
:
-
iotsharp-network
mongodb
:
image
:
mongo:latest
restart
:
always
container_name
:
mongodb
volumes
:
-
./data/mongodb/db:/data/db
-
./data/mongodb/log:/var/log/mongodb
ports
:
-
27017:27017
environment
:
MONGO_INITDB_ROOT_USERNAME
:
root
MONGO_INITDB_ROOT_PASSWORD
:
kissme
networks
:
-
iotsharp-network
networks
:
networks
:
iotsharp-network
:
iotsharp-network
:
driver
:
bridge
driver
:
bridge
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录