1.0.0 • Published 6 years ago

redis-heartbeat v1.0.0

Weekly downloads
17
License
MIT
Repository
github
Last release
6 years ago

redis-heartbeat

Build Status Windows Tests Coveralls Coverage

Deps Status npm version npm downloads

Pulse a heartbeat to redis. This can be used to detach or attach servers to nginx or similar problems.

Breaking changes

Version 1.0.0

  • Since this version the metrics are removed, to be able to install it for node 10.
  • Because of the use of coffee-script 2, also dropped support for node version < 6

Install

  npm install redis-heartbeat

Initialize

	var Heartbeat = require( "redis-heartbeat" );
	var HBInst = new Heartbeat( { name: "FOO", identifier: "http://www.bar.biz:4223" } );
	HBInst.on( "error", function( err ){
		// Init errors 
	} )

Options

  • name : ( String required ) The name of this current service group. E.g. "restservice"
  • identifier : ( String|Function required ) The identifier of the current server. E.g. "http://api.myresthost.com:8080". If also possible to pass in a function that returnes the identifier.
  • intervalHeartbeat : ( Number optional: default = 5 ) Min. interval time ( in seconds ) to send the heartbeat. If set <= 0 the heartbeat will be deactivated.
  • heartbeatKey : ( String optional: default = HB ) Redis key to write the heartbeat. This could be prefixed by redisprefix.
  • heartbeatExpire : ( Number optional: default = 172800 2 days ) Time in seconds until unused heartbeat will automatically removed. If set to 0 the key will never be removed
  • useRedisTime : ( Boolean optional: default = true ) Use redis server time or us the own machine time
  • autostart : ( Boolean optional: default = true ) Start the heartbeat on int. Otherwise you have to call the method .start() of your instance.
  • localtime : ( Boolean optional: default = false ) Force the module to use the local time instead of a server independent local machine time
  • host : ( String optional: default = localhost ) Redis host name
  • port : ( Number optional: default = 6379 ) Redis port
  • options : ( Object optional: default = {} ) Redis options
  • client : ( RedicClient optional: default = null ) It also possible to pass in a already existing redis client instance. In this case the options host, port and options ar ignored.
  • redisprefix : ( String optional: default = {} ) A general redis key prefix
  • diskCheckPath : ( String optional: default = / or c: for win32 ) The disk path to ckeck for free space. If null or empty this check will be skipped. More details see module diskusage

Methods

.start()

Start the heartbeat.

Return

( Booelan ): If it has been started. Could be false if the heartbeat has been already active

.stop()

Stop the heartbeat.

.isActive()

Ask if the heartbeat is currently active.

Return

( Booelan ): Haertbeat is active

.quit()

Stop the heartbeat anc close the internal connection to redis.
After this this instance cannot be reused.

Events

started

Emitted on start of the intervals

beforeHeartbeat

Emitted before heartbeat write. With this event it's possible to change the heartbeat content in operation

Arguments

  • identifier : ( String ) The current identifier

connected

Emitted on connection to redis

disconnect

Emitted on a disconnect of redis

error

An internal error occoured.

redis:error

Emitted on general redis error

Arguments

  • err : ( Error|String ) The error details

TODO

  • add content tests

Release History

VersionDateDescription
1.0.02018-05-07removed metric, to use the heartbeat from node 10
0.3.12017-09-05fixed compiled files
0.3.02017-08-11be able to disable heartbeat with intervalHeartbeat = 0; updated deps; added coverage report
0.2.12016-05-19optimized tests and event handling on quit
0.2.02016-05-18usable from windows; added error event; updated dependencies; better tests
0.1.02016-01-07Added metric p_cpu to measure the process cpu load. Added optional d_avail with the current free disk space. Trigger beforeMetric even if no metricsKey is defined. So you can grab the data without saving it to redis (eg. writing it to elasticsearch or a queue)
0.0.92015-12-15updated dependencies to be used with node 4.2
0.0.82015-05-06fixed time retrieval to use redis time and added a option localtime to force local time. By default it'll use the redis time if connected
0.0.72015-04-27updated dependencies
0.0.62015-04-27added option metricExpire to auto delete unused metrics
0.0.52014-11-20fixed redis key gen method and added ZSET for last active metrics
0.0.32014-11-19added methods .start(), .stop() and .isActive()
0.0.22014-11-19added autostart option
0.0.12014-11-18Initial commit

Other projects

NameDescription
systemhealthNode module to run simple custom checks for your machine or it's connections. It will use redis-heartbeat to send the current state to redis.
rsmqA really simple message queue based on Redis
rsmq-clia terminal client for rsmq
rest-rsmqREST interface for.
redis-notificationsA redis based notification engine. It implements the rsmq-worker to safely create notifications and recurring reports.
nsq-loggerNsq service to read messages from all topics listed within a list of nsqlookupd services.
nsq-topicsNsq helper to poll a nsqlookupd service for all it's topics and mirror it locally.
nsq-nodesNsq helper to poll a nsqlookupd service for all it's nodes and mirror it locally.
nsq-watchWatch one or many topics for unprocessed messages.
node-cacheSimple and fast NodeJS internal caching. Node internal in memory cache like memcached.
redis-sessionsAn advanced session store for NodeJS and Redis
obj-schemaSimple module to validate an object by a predefined schema
connect-redis-sessionsA connect or express middleware to simply use the redis sessions. With redis sessions you can handle multiple sessions per user_id.
task-queue-workerA powerful tool for background processing of tasks that are run by making standard http requests.
soyerSoyer is small lib for serverside use of Google Closure Templates with node.js.
grunt-soy-compileCompile Goggle Closure Templates ( SOY ) templates including the handling of XLIFF language files.
backlunrA solution to bring Backbone Collections together with the browser fulltext search engine Lunr.js

The MIT License (MIT)

Copyright © 2013 Mathias Peter, http://www.tcs.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.0.0

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago