Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid pinger to kill program #95

Closed
anisgandoura opened this issue Feb 3, 2018 · 1 comment
Closed

Avoid pinger to kill program #95

anisgandoura opened this issue Feb 3, 2018 · 1 comment

Comments

@anisgandoura
Copy link

anisgandoura commented Feb 3, 2018

Hello,

When I order a larger number of instances, sometimes, the pinger throws this error: new Error('[ping] should have hostname and port'); making the overall program to restart.

Here is a suggestion for the pinger:

`

if (!options || !options.hostname || !options.port) {
    winston.debug('[Pinger] ping: null / null ');
	
	return new Promise((resolve, reject) => {
		return reject('[ping] should have hostname and port');
	});
	
}else{

	winston.debug('[Pinger] ping: hostname=%s / port=%d', options.hostname, options.port);

	const opts = {
		method: 'GET',
		url: `http://${options.hostname}:${options.port}/ping`,
		timeout: options.timeout || 5000, // Set default timeout to 5s
	};

	return new Promise((resolve, reject) => {			
		request(opts, (err, res, body) => {
			if (err) {
				return reject(err);
			}

			if (res.statusCode !== 200) {
				return reject(body);
			}

			return resolve(body);
		});
	});
}

`

What do you think ?

Best,
Anis

@fabienvauchelles
Copy link
Owner

Hello @anisgandoura ,
Nice idea :)
Will be in next release (4b6c3a5)

Are you still at Station F ?
Fabien.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants