https://github.com/starryinternet/crony
Node.js library for implementing supervisord event listeners.
https://github.com/starryinternet/crony
Last synced: 8 months ago
JSON representation
Node.js library for implementing supervisord event listeners.
- Host: GitHub
- URL: https://github.com/starryinternet/crony
- Owner: StarryInternet
- License: mit
- Created: 2016-10-03T15:02:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-10T16:04:16.000Z (almost 9 years ago)
- Last Synced: 2025-10-14T18:04:43.731Z (8 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crony
[](https://travis-ci.org/StarryInternet/crony)
Node.js library for implementing supervisord event listeners.
*Requires Node.js 6+*
### What?
[supervisord](http://supervisord.org/) implements an [event API](http://supervisord.org/events.html#event-listeners-and-event-notifications)
for listening to changes in state for the processes it manages. `crony` is an
EventEmitter that lets us do stuff with those events in JavaScript.
## Usage
```js
const crony = require('crony');
crony.on( 'event', ev => {
// Global event handler
// token set for the event headers
console.log(`Headers: ${ ev.headers }`);
// token set for the event payload
console.log(`Payload: ${ ev.payload }`);
// If there was an event body, we pass that along, otherwise its undefined
console.log(`Body: ${ ev.body }`);
// We also preserve the raw event string
console.log(`Raw: ${ ev.raw }`);
});
// Additionally, we can also listen to specific events
crony.on( 'PROCESS_STATE_RUNNING', ev => {
// ...
});
// Start listening for events
crony.listen();
```
## Development
```
# Install dependencies
nvm install
npm install
# Run the linter and tests
npm test
```