corebasic 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/kafka.js +31 -30
- package/package.json +1 -1
package/libs/kafka.js
CHANGED
|
@@ -6,7 +6,8 @@ let appName
|
|
|
6
6
|
let topicPrefix = ''
|
|
7
7
|
|
|
8
8
|
function start(arg) {
|
|
9
|
-
|
|
9
|
+
arg = !arg && !process.env.APP_DEPLOYMENT_NAME ? { clientId: (global.app?.name ?? 'app') + '-dev', brokers: ['127.0.0.1:9092'], sasl: false, logLevel: logLevel.ERROR } : arg
|
|
10
|
+
appName = arg?.clientId ?? (process.env.APP_DEPLOYMENT_NAME ?? (global.app?.name ?? 'app'))
|
|
10
11
|
topicPrefix = `${appName}.`
|
|
11
12
|
kafka = new Kafka({
|
|
12
13
|
logLevel: arg?.logLevel ?? logLevel.INFO,
|
|
@@ -121,33 +122,33 @@ module.exports = {
|
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
|
|
124
|
-
const errorTypes = ['unhandledRejection', 'uncaughtException']
|
|
125
|
-
const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']
|
|
125
|
+
// const errorTypes = ['unhandledRejection', 'uncaughtException']
|
|
126
|
+
// const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']
|
|
127
|
+
//
|
|
128
|
+
// errorTypes.forEach(type => {
|
|
129
|
+
// process.on(type, async () => {
|
|
130
|
+
// try {
|
|
131
|
+
// console.log(`process.on ${type}`)
|
|
132
|
+
// if (producer)
|
|
133
|
+
// await producer.disconnect()
|
|
134
|
+
// for (let i = 0; i < consumers.length; i++)
|
|
135
|
+
// await consumers[i].disconnect()
|
|
136
|
+
// process.exit(0)
|
|
137
|
+
// } catch (_) {
|
|
138
|
+
// process.exit(1)
|
|
139
|
+
// }
|
|
140
|
+
// })
|
|
141
|
+
// })
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
signalTraps.forEach(type => {
|
|
143
|
-
process.once(type, async () => {
|
|
144
|
-
try {
|
|
145
|
-
if (producer)
|
|
146
|
-
await producer.disconnect()
|
|
147
|
-
for (let i = 0; i < consumers.length; i++)
|
|
148
|
-
await consumers[i].disconnect()
|
|
149
|
-
} finally {
|
|
150
|
-
process.kill(process.pid, type)
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
})
|
|
143
|
+
// signalTraps.forEach(type => {
|
|
144
|
+
// process.once(type, async () => {
|
|
145
|
+
// try {
|
|
146
|
+
// if (producer)
|
|
147
|
+
// await producer.disconnect()
|
|
148
|
+
// for (let i = 0; i < consumers.length; i++)
|
|
149
|
+
// await consumers[i].disconnect()
|
|
150
|
+
// } finally {
|
|
151
|
+
// process.kill(process.pid, type)
|
|
152
|
+
// }
|
|
153
|
+
// })
|
|
154
|
+
// })
|