Skip to content

Commit

Permalink
20241123 update1
Browse files Browse the repository at this point in the history
  • Loading branch information
neko0xff committed Nov 23, 2024
1 parent e954101 commit 08088a1
Show file tree
Hide file tree
Showing 140 changed files with 15,002 additions and 35 deletions.
Binary file added config/database/sensordb_pgv11.sql.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion config/docker/Dashboard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CC1:=docker compose

.PHONY: build up logs stop clean

all: build
all: stop build

build:
@$(CC1) up --build -d
Expand Down
47 changes: 16 additions & 31 deletions config/docker/Dashboard/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
version: '3.3'

services:
portainer:
image: portainer/portainer-ce
image: portainer/portainer-ce:latest
restart: always
ports:
- 8000:8000
Expand All @@ -12,7 +10,7 @@ services:
- portainer_data:/data

phpmyadmin:
image: phpmyadmin
image: phpmyadmin:latest
restart: always
environment:
PMA_ARBITRARY: 1
Expand All @@ -29,36 +27,23 @@ services:
volumes:
- /var/run/docker.sock:/var/run/docker.sock

grafana:
image: grafana/grafana-oss
restart: always
ports:
- 8086:3000
pgadmin4:
image: dpage/pgadmin4:latest
restart: "always"
environment:
PGADMIN_DEFAULT_EMAIL: "dev@demo.com"
PGADMIN_DEFAULT_PASSWORD: "oitmis"
PGADMIN_CONFIG_SESSION_EXPIRATION_TIME: 365
PGADMIN_CONFIG_MAX_SESSION_IDLE_TIME: 60
volumes:
- /var/run/docker.sock:/var/run/docker.sock

jenkins:
image: jenkins/jenkins:lts
restart: unless-stopped
privileged: true
user: root
- pgadmin4-data:/var/lib/pgadmin
ports:
- 8087:8080
volumes:
- ~/jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/local/bin/docker

jenkins_agent:
image: jenkins/ssh-agent:latest
privileged: true
user: root
expose:
- 2444
environment:
- JENKINS_AGENT_SSH_PUBKEY=${JENKINS_AGENT_SSH_PUBKEY}

- "8082:80"
extra_hosts:
- "host.docker.internal:host-gateway"

volumes:
pgadmin4-data:
external: false
portainer_data:
external: false
6 changes: 3 additions & 3 deletions src/Server/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ services:
restart: always # 跟系統服務一起重啟
network_mode: host # 網路: 使用實體機
build:
context: ./crawlerData
context: ./pg/crawlerData
dockerfile: Dockerfile.env
app2:
container_name: IoTGateway-cont
restart: always # 跟系統服務一起重啟
network_mode: host # 網路: 使用實體機
build:
context: ./IoTGateway
context: ./pg/IoTGateway
dockerfile: Dockerfile.env
app3:
container_name: TelegramB0t-cont
restart: always # 跟系統服務一起重啟
network_mode: host # 網路: 使用實體機
build:
context: ./mqtt_bot_node
context: ./pg/mqtt_bot_node
dockerfile: Dockerfile.env
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/Server/pg/IoTGateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*~
.DS_Store
42 changes: 42 additions & 0 deletions src/Server/pg/IoTGateway/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
"env": {
"commonjs": true,
"es2021": true,
"node": true
},
"extends": "eslint:recommended",
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
};
27 changes: 27 additions & 0 deletions src/Server/pg/IoTGateway/Dockerfile.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 基於的映像檔
FROM node:current-alpine

# 建立工作目錄
WORKDIR /usr/src/app

# 時區
ENV TZ=Asia/Taipei
RUN echo "${TZ}" > /etc/timezone
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime

# 安裝&更新所需的套件
RUN apk update \
apk upgrade --no-cache \
apk add --no-cache icu-data-full tzdata

# 把目錄下的程式碼直接復制到容器中
COPY package*.json ./
RUN npm install
COPY . .

# 指定使用的端口
EXPOSE 3095
EXPOSE 3094

# 容器啟動時
CMD [ "npm", "start" ]
28 changes: 28 additions & 0 deletions src/Server/pg/IoTGateway/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CC1:=docker compose
CC2:=npm
IMAGE:=IoTGateway

.PHONY: build-img build-apidoc up logs stop clean test-mqtt

all: stop clean build-img

build-img:
@$(CC1) up --build -d

build-apidoc:
@$(CC2) run swagger-autogen

test-mqtt:
@$(CC2) run mqttTest-Sub

up:
@$(CC1) up -d

logs:
@$(CC1) logs --tail=100 -f

stop:
@$(CC1) stop

clean:
@$(CC1) down
10 changes: 10 additions & 0 deletions src/Server/pg/IoTGateway/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
server:
container_name: IoTGateway-cont
restart: always # 跟系統服務一起重啟
network_mode: host # 網路: 使用實體機
# 編譯時的設置
build:
context: .
dockerfile: Dockerfile.env

19 changes: 19 additions & 0 deletions src/Server/pg/IoTGateway/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 使用單線程部分
var service=require("./service.js");
var mqttPub=require("./rules/mqtt/Pubtopic.js");

function main(){
service;
mqttPub;
}

/*主程式*/
try {
main();
} catch(error) {
console.log(`Error: ${error}`);
throw error;
}finally {
main();
}

58 changes: 58 additions & 0 deletions src/Server/pg/IoTGateway/modules/clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const moment = require("moment");
var ConfigParser = require("configparser");
const configZone = new ConfigParser();

/*時區設定*/
configZone.read("./modules/config/clockSet.cfg");
configZone.sections();
var locaLang=configZone.get("timezone","locaLang");
var localZone=configZone.get("timezone","localZone");

/*outpuut console Time*/
function consoleTime(){
var clock = new Date();
var nowTime = clock.toLocaleString(locaLang, {timeZone: localZone}); //時區
return nowTime;
}

/*SQL date&time*/
function SQLDate(){
var clock = new moment();
var dateFormat=configZone.get("formatStyle","dateFormat");
var Date=clock.format(dateFormat);
return Date;
}
function SQLTime(){
var clock = new moment();
var timeFormat=configZone.get("formatStyle","timeFormat");
var Time=clock.format(timeFormat);
return Time;
}

/* 將 ISO 8601 日期格式轉換為 "yyyy-mm-dd" 格式 */
function formatDateToYYYYMMDD(isoDateString) {
const date = new Date(isoDateString);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Month is 0-based
const day = String(date.getDate()).padStart(2, '0');

return `${year}-${month}-${day}`;
}

/*Yasterday a Date: 格式= 'YYYY-MM-DD'*/
function yasterDate(){
const today = new Date();
const yesterday = new Date(today);

yesterday.setDate(today.getDate() - 1);
const formattedYesterday = yesterday.toISOString().slice(0, 10);
return formattedYesterday;
}

module.exports={
yasterDate:yasterDate,
formatDateToYYYYMMDD:formatDateToYYYYMMDD,
consoleTime:consoleTime,
SQLDate:SQLDate,
SQLTime:SQLTime
};
7 changes: 7 additions & 0 deletions src/Server/pg/IoTGateway/modules/config/clockSet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[timezone]
locaLang = zh-TW
localZone = Asia/Taipei

[formatStyle]
timeFormat = HH:mm:ss
dateFormat = YYYY-MM-DD
10 changes: 10 additions & 0 deletions src/Server/pg/IoTGateway/modules/config/cnSet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[POSTGRESQL]
DBsource = localhost
DBuser = postgres
DBpassword = oitmis
DBport = 5432
cnDatabase = sensordb

[MQTT]
source = localhost
port = 3094
3 changes: 3 additions & 0 deletions src/Server/pg/IoTGateway/modules/config/serviceSet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Service]
MQTT = 3094
HTTP = 3095
Loading

0 comments on commit 08088a1

Please sign in to comment.