feat: add .env config file (POLL_INTERVAL_MS, PORT, LOG_LEVEL)
This commit is contained in:
1 parent
11b79075a5
commit
786c063e4a
6 files changed
+31
-1
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
PORT=3000
|
||||||
|
POLL_INTERVAL_MS=1000
|
||||||
|
LOG_LEVEL=1
|
||||||
|
# SKIP_PLC=1
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# 服务器端口
|
||||||
|
PORT=3000
|
||||||
|
|
||||||
|
# PLC 轮询间隔(毫秒)
|
||||||
|
POLL_INTERVAL_MS=1000
|
||||||
|
|
||||||
|
# 日志级别: 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR
|
||||||
|
LOG_LEVEL=1
|
||||||
|
|
||||||
|
# 跳过 PLC 连接(开发时用)
|
||||||
|
# SKIP_PLC=1
|
||||||
Generated
+13
@@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/node-server": "^1.14.0",
|
"@hono/node-server": "^1.14.0",
|
||||||
"better-sqlite3": "^11.8.0",
|
"better-sqlite3": "^11.8.0",
|
||||||
|
"dotenv": "^17.4.2",
|
||||||
"hono": "^4.7.0",
|
"hono": "^4.7.0",
|
||||||
"node-snap7": "^1.0.9"
|
"node-snap7": "^1.0.9"
|
||||||
},
|
},
|
||||||
@@ -608,6 +609,18 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dotenv": {
|
||||||
|
"version": "17.4.2",
|
||||||
|
"resolved": "https://repo.huaweicloud.com/repository/npm/dotenv/-/dotenv-17.4.2.tgz",
|
||||||
|
"integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://dotenvx.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/end-of-stream": {
|
"node_modules/end-of-stream": {
|
||||||
"version": "1.4.5",
|
"version": "1.4.5",
|
||||||
"resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
"resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/node-server": "^1.14.0",
|
"@hono/node-server": "^1.14.0",
|
||||||
"better-sqlite3": "^11.8.0",
|
"better-sqlite3": "^11.8.0",
|
||||||
|
"dotenv": "^17.4.2",
|
||||||
"hono": "^4.7.0",
|
"hono": "^4.7.0",
|
||||||
"node-snap7": "^1.0.9"
|
"node-snap7": "^1.0.9"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dotenv/config'
|
||||||
import { serve } from '@hono/node-server'
|
import { serve } from '@hono/node-server'
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import { logger } from './logger.js'
|
import { logger } from './logger.js'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { STATION_SIZE, OFFSET,
|
|||||||
readDINT, readREAL, readWORD, parseControlWord } from './protocol.js'
|
readDINT, readREAL, readWORD, parseControlWord } from './protocol.js'
|
||||||
|
|
||||||
const TAG = 'Scanner'
|
const TAG = 'Scanner'
|
||||||
const POLL_INTERVAL_MS = 1000
|
const POLL_INTERVAL_MS = parseInt(process.env.POLL_INTERVAL_MS || '1000', 10)
|
||||||
|
|
||||||
let timer: ReturnType<typeof setInterval> | null = null
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
let plcConfigs: PLCConfig[] = []
|
let plcConfigs: PLCConfig[] = []
|
||||||
|
|||||||
Reference in new issue
Block a user