New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hydra-express

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydra-express - npm Package Compare versions

Comparing version 1.2.20-experimental to 1.2.21-experimental

96

index.js

@@ -29,3 +29,2 @@ /**

const bodyParser = require('body-parser');
const cluster = require('cluster');
const cors = require('cors');

@@ -36,3 +35,2 @@ const express = require('express');

const moment = require('moment');
const os = require('os');
const path = require('path');

@@ -300,79 +298,29 @@ const responseTime = require('response-time');

start(resolve, _reject) {
if (!this.config.cluster || this.config.cluster !== true) {
let serviceInfo;
hydra.init(this.config)
.then((config) => {
this.config = config;
return hydra.registerService();
})
.then((_serviceInfo) => {
serviceInfo = _serviceInfo;
this.log('start', `${this.config.hydra.serviceName} (v.${this.config.version}) server listening on port ${this.config.hydra.servicePort}`);
this.log('info', `Using environment: ${this.config.environment}`);
this.initWorker();
return Promise.series(this.registeredPlugins, (plugin) => plugin.onServiceReady());
})
.then((..._results) => {
return Promise.delay(2000);
})
.then(() => resolve(serviceInfo))
.catch((err) => this.log('error', err.toString()));
} else {
if (cluster.isMaster) {
const numWorkers = this.config.processes || os.cpus().length;
console.log(`${this.config.hydra.serviceName} (v.${this.config.version})`);
console.log(`Using environment: ${this.config.environment}`);
console.log('info', `Master cluster setting up ${numWorkers} workers...`);
for (let i = 0; i < numWorkers; i++) {
cluster.fork();
}
/**
* @param {object} worker - worker process object
*/
cluster.on('online', (worker) => {
this.log('info', `Worker ${worker.process.pid} is online`);
});
/**
* @param {object} worker - worker process object
* @param {number} code - process exit code
* @param {number} signal - signal that caused the process shutdown
*/
cluster.on('exit', (worker, code, signal) => {
this.log('error', `Worker ${worker.process.pid} died with code ${code}, and signal: ${signal}`);
this.log('info', 'Starting a new worker');
cluster.fork();
});
resolve({});
} else {
hydra.init(this.config)
.then((config) => {
this.config = config;
return hydra.registerService();
})
.then((_serviceInfo) => {
this.initWorker();
Promise.delay(2000).then(() => {
resolve({
serviceName: this.config.hydra.serviceName,
serviceIP: this.config.hydra.serviceIP,
servicePort: this.config.hydra.servicePort
});
});
});
}
}
let serviceInfo;
hydra.init(this.config)
.then((config) => {
this.config = config;
return hydra.registerService();
})
.then((_serviceInfo) => {
serviceInfo = _serviceInfo;
this.log('start', `${this.config.hydra.serviceName} (v.${this.config.version}) server listening on port ${this.config.hydra.servicePort}`);
this.log('info', `Using environment: ${this.config.environment}`);
this.initService();
return Promise.series(this.registeredPlugins, (plugin) => plugin.onServiceReady());
})
.then((..._results) => {
return Promise.delay(2000);
})
.then(() => resolve(serviceInfo))
.catch((err) => this.log('error', err.toString()));
}
/**
* @name initWorker
* @summary Initialize a worker process
* @name initService
* @summary Initialize service
* @private
* @return {undefined}
*/
initWorker() {
initService() {
app.use(cors());

@@ -664,3 +612,3 @@ app.use(responseTime());

registerRoutesCallback = version;
inner.version = config.version || require('./package.json').version;
inner.version = config.version || require(`${__dirname}/package.json`).version;
} else if (version) {

@@ -667,0 +615,0 @@ inner.version = version;

{
"name": "hydra-express",
"version": "1.2.20-experimental",
"version": "1.2.21-experimental",
"description": "A module which wraps Hydra and ExpressJS to provide an out of the box microservice which can support API routes and handlers.",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc