@sentio/runtime 2.7.2 → 2.7.3-rc.2
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/lib/processor-runner.js
CHANGED
@@ -94,7 +94,7 @@ server.add(ProcessorDefinition, service);
|
|
94
94
|
server.listen('0.0.0.0:' + options.port);
|
95
95
|
console.log('Processor Server Started at:', options.port);
|
96
96
|
const metricsPort = 4040;
|
97
|
-
http
|
97
|
+
const httpServer = http
|
98
98
|
.createServer(async function (req, res) {
|
99
99
|
if (req.url && new URL(req.url, `http://${req.headers.host}`).pathname === '/metrics') {
|
100
100
|
const metrics = await mergedRegistry.metrics();
|
@@ -107,4 +107,12 @@ http
|
|
107
107
|
})
|
108
108
|
.listen(metricsPort);
|
109
109
|
console.log('Metric Server Started at:', metricsPort);
|
110
|
+
process.on('SIGINT', function () {
|
111
|
+
server.forceShutdown();
|
112
|
+
console.log('RPC server shut down');
|
113
|
+
httpServer.close(function () {
|
114
|
+
console.log('Http server shut down');
|
115
|
+
process.exit(0);
|
116
|
+
});
|
117
|
+
});
|
110
118
|
//# sourceMappingURL=processor-runner.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,QAA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,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,UAAU,GAAG,IAAI;KACpB,YAAY,CAAC,KAAK,WAAW,GAAG,EAAE,GAAG;IACpC,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,KAAK,UAAU,EAAE;QACrF,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;QAC9C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;KACnB;SAAM;QACL,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KACnB;IACD,GAAG,CAAC,GAAG,EAAE,CAAA;AACX,CAAC,CAAC;KACD,MAAM,CAAC,WAAW,CAAC,CAAA;AAEtB,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;AAErD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE;IACnB,MAAM,CAAC,aAAa,EAAE,CAAA;IACtB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;IAEnC,UAAU,CAAC,KAAK,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;QACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { compressionAlgorithms } from '@grpc/grpc-js'\n\nimport { register as globalRegistry, Registry } from 'prom-client'\nimport { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus'\nimport http from 'http'\n\nconst mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])\n\nimport { ProcessorDefinition } from './gen/processor/protos/processor.js'\nimport { ProcessorServiceImpl } from './service.js'\nimport { Endpoints } from './endpoints.js'\n\nimport { FullProcessorServiceImpl } from './full-service.js'\nimport { ChainConfig } from './chain-config.js'\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n // { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nEndpoints.INSTANCE.concurrency = options.concurrency\nEndpoints.INSTANCE.chainQueryAPI = options['chainquery-server']\nEndpoints.INSTANCE.priceFeedAPI = options['pricefeed-server']\n\nfor (const [id, config] of Object.entries(chainsConfig)) {\n const chainConfig = config as ChainConfig\n if (chainConfig.ChainServer) {\n Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)\n } else {\n const http = chainConfig.Https?.[0]\n if (http) {\n Endpoints.INSTANCE.chainServer.set(id, http)\n } else {\n console.error('not valid config for chain', id)\n }\n }\n}\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': compressionAlgorithms.gzip,\n}).use(prometheusServerMiddleware())\n\nconst baseService = new ProcessorServiceImpl(async () => {\n const m = await import(options.target)\n if (options.debug) {\n console.log('Module loaded', m)\n }\n return m\n}, server.shutdown)\nconst service = new FullProcessorServiceImpl(baseService)\n\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started at:', options.port)\n\nconst metricsPort = 4040\nconst httpServer = http\n .createServer(async function (req, res) {\n if (req.url && new URL(req.url, `http://${req.headers.host}`).pathname === '/metrics') {\n const metrics = await mergedRegistry.metrics()\n res.write(metrics)\n } else {\n res.writeHead(404)\n }\n res.end()\n })\n .listen(metricsPort)\n\nconsole.log('Metric Server Started at:', metricsPort)\n\nprocess.on('SIGINT', function () {\n server.forceShutdown()\n console.log('RPC server shut down')\n\n httpServer.close(function () {\n console.log('Http server shut down')\n process.exit(0)\n })\n})\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "2.7.2",
|
4
|
+
"version": "2.7.3-rc.2",
|
5
5
|
"scripts": {
|
6
6
|
"compile": "tsc",
|
7
7
|
"build": "yarn compile",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"start_js": "ts-node-esm --files ./lib/processor-runner.js $PWD/../../debug/dist/lib.js"
|
14
14
|
},
|
15
15
|
"dependencies": {
|
16
|
-
"@sentio/protos": "^2.7.2",
|
16
|
+
"@sentio/protos": "^2.7.3-rc.2",
|
17
17
|
"command-line-args": "^5.2.1",
|
18
18
|
"command-line-usage": "^7.0.1",
|
19
19
|
"fs-extra": "^11.0.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"!{lib,src}/tests",
|
46
46
|
"!**/*.test.{js,ts}"
|
47
47
|
],
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "35d887bfdd25631e12d1aa3efefce1451b995dab"
|
49
49
|
}
|
package/src/processor-runner.ts
CHANGED
@@ -118,7 +118,7 @@ server.listen('0.0.0.0:' + options.port)
|
|
118
118
|
console.log('Processor Server Started at:', options.port)
|
119
119
|
|
120
120
|
const metricsPort = 4040
|
121
|
-
http
|
121
|
+
const httpServer = http
|
122
122
|
.createServer(async function (req, res) {
|
123
123
|
if (req.url && new URL(req.url, `http://${req.headers.host}`).pathname === '/metrics') {
|
124
124
|
const metrics = await mergedRegistry.metrics()
|
@@ -131,3 +131,13 @@ http
|
|
131
131
|
.listen(metricsPort)
|
132
132
|
|
133
133
|
console.log('Metric Server Started at:', metricsPort)
|
134
|
+
|
135
|
+
process.on('SIGINT', function () {
|
136
|
+
server.forceShutdown()
|
137
|
+
console.log('RPC server shut down')
|
138
|
+
|
139
|
+
httpServer.close(function () {
|
140
|
+
console.log('Http server shut down')
|
141
|
+
process.exit(0)
|
142
|
+
})
|
143
|
+
})
|