-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
willem
committed
Feb 28, 2024
1 parent
c52d15c
commit 86b63ea
Showing
301 changed files
with
29,710 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
services: | ||
redis: | ||
image: redis:7.0.11 | ||
container_name: redis-server | ||
restart: always | ||
volumes: | ||
- "./redis/conf/redis.conf:/usr/local/etc/redis/redis.conf" | ||
- "./redis/data:/data" | ||
- "./redis/logs:/logs" | ||
command: ["redis-server","/usr/local/etc/redis/redis.conf"] | ||
environment: | ||
- TZ=Asia/Shanghai | ||
ports: | ||
- 6379:6379 | ||
tdengine: | ||
image: tdengine/tdengine:3.2.1.0 | ||
container_name: tdengine-server | ||
restart: always | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- "./taos/dnode/data:/var/lib/taos" | ||
- "./taos/dnode/log:/var/log/taos" | ||
ports: | ||
- 6030:6030 | ||
- 6041:6041 | ||
emqx: | ||
image: emqx/emqx:5.0.26 | ||
restart: always | ||
container_name: emqx-server | ||
environment: | ||
- TZ=Asia/Shanghai | ||
# volumes: | ||
# - ./emqx/data:/opt/emqx/data | ||
# - ./emqx/log:/opt/emqx/log | ||
ports: | ||
- 1883:1883 | ||
- 8083:8083 | ||
- 8084:8084 | ||
- 8883:8883 | ||
- 18083:18083 | ||
mysql: | ||
image: mysql:8.0.25 | ||
container_name: mysql-server | ||
restart: always | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=DbyTYGu3s4WuAF4TTq7 | ||
- MYSQL_DATABASE=sagoo_iot_open | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- ./mysql/init:/docker-entrypoint-initdb.d | ||
- ./mysql/data:/var/lib/mysql | ||
- ./mysql/logs:/var/log | ||
ports: | ||
- "3306:3306" | ||
nginx: | ||
extends: | ||
file: ./nginx/nginx.yaml | ||
service: nginx | ||
|
||
sagoo-iot-open: | ||
extends: | ||
file: ./iot-open/iot-open.yaml | ||
service: sagoo-iot-open | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM golang:alpine AS builder | ||
RUN apk add --no-cache tzdata && \ | ||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | ||
echo "Asia/Shanghai" > /etc/timezone | ||
|
||
WORKDIR /opt/sagoo-iot-server/ | ||
|
||
COPY ./config/ /opt/sagoo-iot-server/config | ||
|
||
COPY ./curl.sh /opt/sagoo-iot-server/ | ||
COPY ./entrypoint.sh /opt/sagoo-iot-server/ | ||
COPY ./sagooiot /opt/sagoo-iot-server/ | ||
|
||
COPY ./entrypoint.sh /opt/sagoo-iot-server/ | ||
RUN chmod +x /opt/sagoo-iot-server/entrypoint.sh | ||
RUN chmod +x /opt/sagoo-iot-server/sagooiot | ||
|
||
COPY ./resource/public /opt/sagoo-iot-server/resource/public/ | ||
COPY ./resource/rsa /opt/sagoo-iot-server/resource/rsa/ | ||
COPY ./resource/app.lic /opt/sagoo-iot-server/resource | ||
|
||
EXPOSE 8200 | ||
|
||
CMD ["/bin/sh", "-c", "sleep 50 && /opt/sagoo-iot-server/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# 系统配置 | ||
system: | ||
name: "sagooiot" | ||
version: "2.0" | ||
description: "SagooIoT Server" | ||
enablePProf: true # 是否开启pprof | ||
# pprofPort: "58088" # pprof端口 | ||
ipMethod: "whois" # IP归属地解析方法,可选:cz88|whois,默认为whois | ||
isDemo: false # 是否为演示系统 | ||
isCluster: false # 是否为集群部署,默认为false。开启集群必须配置redis | ||
deviceCacheData: | ||
poolSize: 300 #设备数据缓存池连接数 | ||
recordDuration: "20m" #设备数据缓存时长,超过时长的数据将被清除。默认为10分钟 | ||
recordLimit: 1000 #设备数据缓存条数限制,超过条数的数据将被清除。默认为1000条 | ||
pluginsPath: "./plugins/built" | ||
# 文件上传设置 | ||
upload: | ||
path: "upload" | ||
|
||
#缓存 | ||
cache: | ||
prefix: "SagooIot_Sys:" #缓存前缀 | ||
adapter: "redis" # 缓存驱动方式,支持:memory|redis|file,不填默认memory | ||
fileDir: "./storage/cache" # 文件缓存路径,adapter=file时必填 | ||
|
||
# http服务配置 | ||
server: | ||
serverAgent: "SagooIOT Server" # 服务端Agent信息。 | ||
address: ":8200" | ||
dumpRouterMap: false | ||
routeOverWrite: true | ||
openapiPath: "/api.json" | ||
swaggerPath: "/swagger" | ||
NameToUriType: 3 | ||
maxHeaderBytes: "20KB" | ||
clientMaxBodySize: "50MB" | ||
# Logging配置 | ||
logPath: "resource/log/server" # 日志文件存储目录路径,建议使用绝对路径。默认为空,表示关闭 | ||
logStdout: false # 日志是否输出到终端。默认为true | ||
errorStack: true # 当Server捕获到异常时是否记录堆栈信息到日志中。默认为true | ||
errorLogEnabled: true # 是否记录异常日志信息到日志中。默认为true | ||
errorLogPattern: "error-{Ymd}.log" # 异常错误日志文件格式。默认为"error-{Ymd}.log" | ||
accessLogEnabled: true # 是否记录访问日志。默认为false | ||
accessLogPattern: "access-{Ymd}.log" # 访问日志文件格式。默认为"access-{Ymd}.log" | ||
https: false | ||
httpsCertFile: "" | ||
httpsKeyFile: "" | ||
# 静态服务配置 | ||
indexFiles: [ "index.html"] # 自动首页静态文件检索。默认为["index.html", "index.htm"] | ||
indexFolder: false # 当访问静态文件目录时,是否展示目录下的文件列表。默认关闭,那么请求将返回403 | ||
serverRoot: "resource/public" # 静态文件服务的目录根路径,配置时自动开启静态文件服务。默认关闭 | ||
searchPaths: [ "/resource/public/"] # 提供静态文件服务时额外的文件搜索路径,当根路径找不到时则按照顺序在搜索目录查找。默认关闭 | ||
fileServerEnabled: true # 是否开启静态文件服务。默认为false | ||
adminPprofPort: "58089" # web-admin pprof端口 | ||
# allowedDomains: #允许跨域访问的域名列表 | ||
# - https://example.com | ||
# - https://www.example.com | ||
|
||
logger: | ||
level : "all" | ||
stdout: true | ||
|
||
#GFToken | ||
gfToken: | ||
timeOut: 10800 #token超时时间(秒) | ||
maxRefresh: 5400 #token自动刷新时间(秒) | ||
multiLogin: true #是否允许一个账号多人同时登录 | ||
encryptKey: "49c54195e750b04e74a8429b17896586" #加密key (32位) | ||
excludePaths: #排除不做登录验证的路由地址 | ||
- "/api/v1/login" | ||
- "/api/v1/sysinfo" | ||
|
||
# 数据库连接配置 | ||
database: | ||
logger: | ||
path: "resource/log/sql" | ||
level: "all" | ||
stdout: false | ||
ctxKeys: [ "RequestId" ] | ||
default: | ||
link: "mysql:root:DbyTYGu3s4WuAF4TTq7@tcp(mysql:3306)/sagoo_iot_open?loc=Local&parseTime=true" | ||
debug: true #开启调试模式 | ||
charset: "utf8mb4" #数据库编码(如: utf8/gbk/gb2312),一般设置为utf8 | ||
dryRun: false #ORM空跑(只读不写) | ||
maxIdle: 50 #连接池最大闲置的连接数 | ||
maxOpen: 100 #连接池最大打开的连接数 | ||
maxLifetime: 60 #(单位秒)连接对象可重复使用的时间长度 | ||
|
||
# 这个mqtt客户端主要是服务端内部处理消息使用的通道 | ||
mqtt: | ||
addr: emqx:1883 | ||
# 最好带上服务名称,变成唯一id | ||
clientId: sagooiot20230916 | ||
deviceLiveDuration: 60 | ||
qos: 1 | ||
auth: | ||
userName: xinjy | ||
userPassWorld: 123456 | ||
|
||
# 时序数据库配置 | ||
tsd: | ||
database: "TdEngine" | ||
tdengine: | ||
# type: "taosRestful" #http连接方式,端口是6041 | ||
# dsn: "root:taosdata@http(127.0.0.1:6041)/" | ||
type: "taosWS" #http连接方式,端口是6041 | ||
dsn: "root:taosdata@ws(tdengine:6041)/" | ||
dbName: "sagoo_iot" | ||
maxOpenConns: 1000 | ||
maxIdleConns: 50 | ||
|
||
# Redis 配置示例 | ||
redis: | ||
# 单实例配置 | ||
default: | ||
address: redis:6379 | ||
db: 0 | ||
pass: FDXLK3LdGYYk9mut | ||
minIdle: 50 #最小空闲连接数 | ||
maxIdle: 100 #允许闲置的最大连接数 | ||
maxActive: 16 #最大活跃连接数 | ||
idleTimeout: "30m" #连接最大空闲时间,使用时间字符串例如30s/2m/2d | ||
|
||
#消息队列 | ||
queue: | ||
switch: true # 队列开关,可选:true|false,默认为true | ||
driver: "redis" # 队列驱动,可选:redis|rocketmq|kafka,默认为disk | ||
retry: 2 # 重试次数,仅rocketmq|redis支持 | ||
groupName: "sagooiot" # mq群组名称 | ||
redis: | ||
address: "redis:6379" # redis服务地址,默认为127.0.0.1:6379 | ||
db: 0 # 指定redis库 | ||
pass: "FDXLK3LdGYYk9mut" # redis密码 | ||
timeout: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
WORKSPACE=$(cd "$(dirname "$0")" || exit; pwd) | ||
cd "$WORKSPACE" || exit | ||
|
||
readonly app='sagooiot' | ||
readonly pidfile="var/$app.pid" | ||
readonly logfile="var/$app.log" | ||
|
||
mkdir -p var | ||
|
||
check_pid() { | ||
if [[ -f $pidfile ]]; then | ||
local pid=$(cat "$pidfile") | ||
if [[ -n $pid ]]; then | ||
local running=$(ps -p "$pid" | grep -c -v "PID TTY") | ||
return "$running" | ||
fi | ||
fi | ||
return 0 | ||
} | ||
|
||
start() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
printf "%s now is running already, pid: %s\n" "$app" "$(cat "$pidfile")" | ||
return 1 | ||
fi | ||
|
||
nohup "./$app" >> "$logfile" 2>&1 & | ||
sleep 1 | ||
running=$(ps -p $! | grep -c -v "PID TTY") | ||
if [[ $running -gt 0 ]]; then | ||
echo $! > "$pidfile" | ||
printf "%s started... pid: %s\n" "$app" "$!" | ||
else | ||
printf "%s failed to start.\n" "$app" | ||
return 1 | ||
fi | ||
} | ||
|
||
stop() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
local pid=$(cat "$pidfile") | ||
kill "$pid" | ||
rm -f "$pidfile" | ||
printf "%s stopped.\n" "$app" | ||
else | ||
printf "%s is not running.\n" "$app" | ||
fi | ||
} | ||
|
||
restart() { | ||
stop | ||
sleep 1 | ||
start | ||
} | ||
|
||
status() { | ||
check_pid | ||
local running=$? | ||
if [[ $running -gt 0 ]]; then | ||
printf "%s is started.\n" "$app" | ||
else | ||
printf "%s is stopped.\n" "$app" | ||
fi | ||
} | ||
|
||
tailf() { | ||
tail -f var/* | ||
} | ||
|
||
print_help() { | ||
printf "Usage: %s {start|stop|restart|status|tail|pid}.\n" "$0" | ||
} | ||
|
||
print_pid() { | ||
cat "$pidfile" | ||
} | ||
|
||
main() { | ||
case "$1" in | ||
"start") start ;; | ||
"stop") stop ;; | ||
"restart") restart ;; | ||
"status") status ;; | ||
"tail") tailf ;; | ||
"pid") print_pid ;; | ||
*) print_help ;; | ||
esac | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
# 这里是其他的启动逻辑或命令 | ||
/opt/sagoo-iot-server/sagooiot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
services: | ||
sagoo-iot-open: | ||
image: sagoo-iot-open:1.0.2 | ||
restart: always | ||
container_name: sagoo-iot-open | ||
build: | ||
dockerfile: ./Dockerfile | ||
depends_on: | ||
- mysql | ||
- redis | ||
- emqx | ||
- tdengine | ||
ports: | ||
- 8200:8200 | ||
volumes: | ||
- "./resource/public/upload_file/:/opt/sagoo-iot-server/resource/public/upload_file" | ||
- "./resource/log/:/opt/sagoo-iot-server/resource/log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
QkRwkVEZyUfv8QzuNRg43+YI4KCD005A6rDwRTezAtdVa5wyZbf2eBM3bBRGmijjOyRzTsG3mARPSieqMfHvqGklCP5gvEPJXFOCQ1aysseGh+V/2vRTqPW+LwfqAiMnkWtJsjaXS5usT3yddyN0Rhu7ZIpKRhL7foUviAtIy6sDknFOxV3X3K97K6MrLp/Qp9N8Il6JjAV7s4atmLIzMz9qosX10tATDkr+L7S2rJ0rWWMGhqkj2Js5kU4iF96KgZPdFV9DJCqjpbiUrinInrzn0MJ/5OTHThdm9X9p/XCtjd+ZmYK1ka8xHVrYt5dtCg7AQ/Z4v3fQMiYkuiK7UWLVkTp7mmc5IFQ+zjHWN1pWD3qc4EI+BY3WLGgKqeC3GFPgELZ/RuBSHz5XtGsvVQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDCsnMIAnRpqu3z | ||
ZjYHmqixlG/ynV0ZfagsWvWwCsnF69bdrW/txUDRThZ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uw5ucfXITpFQD8ThzSjBkhrOk4fItWhkN5ED41 | ||
oEhrdUoL3N/WDpyFoQB7Aa9q1Y1iG2bRY9swMUN8inknGCRoT894cueERed0doqz | ||
rYvey1TAalwW7zoRcxnbEyhLJoge9jiTmRaivXD7XFOmuf6HRBjGIIlz9lECgYBs | ||
E/VbPjZbuPA/3hZb9l7w2gk0P5HCGmwtLK6zJkJ4geM65wD9u3AfibQ5Kx742iNV | ||
TWALEf/V97txChW/6+fElAtCPlB2i7beGzompRP2tbS+2pjlbYDZVf9FhyWJD4Mu | ||
lvr/4Hl8mZzWaDjK7I+hD7/13Wlya5tFn2iKwbjAvQKBgQCLiRluLqvhELCyP6VL | ||
3Os3qdb8rLbgMz9ttaxsuI7wDW8g40AkU4iwxzSQRBiCGOMtQHWS3xLxHLSAjUvG | ||
MSdanpimagZ8aHsWo5FtL/oqucHrd1qd7SUb/r/A7HhTctwrV07j+ru2kExnNIGW | ||
/p/L0H4Yz1blO0d6L7EF+3emKA== | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwrJzCAJ0aart82Y2B5qo | ||
sZRv8p1dGX2oLFr1sArJxevW3a1v7cVA0U4WVFJdifDVFpsuich9nsfhUp7CNOZn | ||
a+rNveglzYlrtMhqynYU+bKUBBAmYaVyDHOpxkp86fhp0q7qoX8YoeSvYRaVaPoF | ||
HRYeahy0d3L+gL8pRhr0k70RZMraC3zzXbuUcM7GNibiKbFiQllhlGlfbV0bmOH8 | ||
LZcwWwv40Ptdd4x2gihn5vmzGdQ1OAf3D6YmtsXf7iMj0H1g5svyHs17ncSN7h9i | ||
WTrVKcNDxrl1dm4BRsxDJsWenwrIM1WUHuonlbE6OoIJEO25T3ucymzWDzMSWxe3 | ||
sQIDAQAB | ||
-----END PUBLIC KEY----- |
Binary file not shown.
Oops, something went wrong.