- Starting and stopping processes
- Controlling the Daemon
- Managing clusters
- Installing and running apps
- Remote access and monitoring (e.g. guv-web)
- Web interface
- Web interface - configuration
- Web interface - user management
- Programmatic access
- Programmatic access - local
- Programmatic access - remote
- Programmatic access - events
The guvnor daemon is a wildemitter so you can use wildcards to listen for events:
guvnor.on('*', function() {
var type = arguments[0]
var args = Array.prototype.slice.call(arguments, 1)
console.info(type, 'emitted with args', args)
})
These are events that are to do with managed processes. They are emitted by processes, cluster managers and workers. For example:
guvnor.on('process:starting', function(processInfo) {
console.info('process %s is starting', processInfo.name)
})
guvnor.on('cluster:starting', function(clusterInfo) {
console.info('cluster %s is starting', clusterInfo.name)
})
guvnor.on('worker:starting', function(clusterInfo, workerInfo) {
console.info('worker %s from cluster %s is starting', workerInfo.id, clusterInfo.name)
})
Note that the signature for cluster worker events is slightly different - they receive both the cluster and worker process information.
### 'process:starting' processInfo
A process is about to be created.
### 'process:forked' processInfo
A process is now active (although the v8 instance behind it may still be initialising).
### 'process:failed' processInfo, error
A process wrapper initialised incorrectly - hopefully you will never see this
### 'process:started' processInfo
A process has started and your module code has been loaded.
### 'process:errored' processInfo, error
Your module code threw an exception on start up.
### 'process:ready' processInfo
A connection has been established between guvnor and the managed process. All systems go.
A process is about to stop.
A process experienced an uncaught exception after startup.
### 'process:fatality' processInfo
A process experienced an uncaught exception and there were no handlers for the exception. The process will now exit with a non-zero error code which will cause it to be be restarted.
A process exited or errored with the specified error code. If a signal was used to kill the process, it will be passed as the second argument. If the exit code is non-zero the process will be automatically restarted.
A process restarted successfully.
A process failed to (re)start because it error'd on startup more times than allowed.
A managed process has requested configuration from guvnor
Cluster events are divided into two types - cluster and worker. Cluster events are emitted by the process that manages cluster workers and worker events are emitted by the workers themselves.
A cluster manager is starting
A cluster manager has started and can be connect to
A cluster manager has failed to start
A cluster manager and all it's worker processes are ready
A new cluster worker was created
A worker is about to get killed
A worker exited with the passed code. If a signal was used to kill the worker, it is passed as the third argument to the callback.
These are events that are to do with the guvnor daemon itself.
Guvnor crashed. Hopefully you'll never see this.
The daemon is about to shut down cleanly, usually in response to the guv kill
command.
The daemon has written process information out to /etc/guvnor/processes.json
, usually in response to the guv dump
command.
The daemon has loaded process information from /etc/guvnor/processes.json
if available, usually in response to the guv restore
command.
Guvnor is sending configuration to a managed process
App events related to installed apps. An app is a node.js program installed from a git repository containing a package.json
file at it's root.
An app was installed. The passed appInfo
object contains the name, url, etc of the new app.
An app was removed and all files deleted from the filesystem. The passed appInfo
object contains the name, url, etc of the removed app.
New app refs were pulled from the upstream repository. The passed appInfo
object represents the app and refs
is the list of available ref names. A ref is a git branch or tag.
The app represented by appInfo
was switched from oldRef
to newRef
. A ref is a git branch or tag.
## Log events
There are four types of log event: info
, warn
, error
and debug
. Log events are emitted by processes, cluster managers, cluster workers and the guvnor daemon itself.
info
and error
correspond to stdout and stderr.
A process emitted an info log event. The log object contains the time and the message.
guvnor.on('process:log:info', function(processInfo, log) {
console.info('process %s said %s at %s', processInfo.name, log.message, log.date)
})
guvnor.on('cluster:log:info', function(clusterInfo, log) {
console.info('cluster manager %s said %s at %s', clusterInfo.name, log.message, log.date)
})
guvnor.on('worker:log:info', function(clusterInfo, workerInfo, log) {
console.info('worker %s from cluster %s said %s at %s', workerInfo.id, cluster.name, log.message, log.date)
})
guvnor.on('daemon:log:info', function(log) {
console.info('guvnor said %s at %s', log.message, log.date)
})
A process emitted an warn log event. The log object contains the time and the message.
guvnor.on('process:log:warn', function(processInfo, log) {
console.warn('process %s said %s at %s', processInfo.name, log.message, log.date)
})
guvnor.on('cluster:log:warn', function(clusterInfo, log) {
console.warn('cluster manager %s said %s at %s', clusterInfo.name, log.message, log.date)
})
guvnor.on('worker:log:warn', function(clusterInfo, workerInfo, log) {
console.warn('worker %s from cluster %s said %s at %s', workerInfo.id, cluster.name, log.message, log.date)
})
guvnor.on('daemon:log:warn', function(log) {
console.warn('guvnor said %s at %s', log.message, log.date)
})
A process emitted an error log event. The log object contains the time and the message.
guvnor.on('process:log:error', function(processInfo, log) {
console.error('process %s said %s at %s', processInfo.name, log.message, log.date)
})
guvnor.on('cluster:log:error', function(clusterInfo, log) {
console.error('cluster manager %s said %s at %s', clusterInfo.name, log.message, log.date)
})
guvnor.on('worker:log:error', function(clusterInfo, workerInfo, log) {
console.error('worker %s from cluster %s said %s at %s', workerInfo.id, cluster.name, log.message, log.date)
})
guvnor.on('daemon:log:error', function(log) {
console.error('guvnor said %s at %s', log.message, log.date)
})
A process emitted an debug log event. The log object contains the time and the message.
guvnor.on('process:log:debug', function(processInfo, log) {
console.info('process %s said %s at %s', processInfo.name, log.message, log.date)
})
guvnor.on('cluster:log:debug', function(clusterInfo, log) {
console.info('cluster manager %s said %s at %s', clusterInfo.name, log.message, log.date)
})
guvnor.on('worker:log:debug', function(clusterInfo, workerInfo, log) {
console.info('worker %s from cluster %s said %s at %s', workerInfo.id, cluster.name, log.message, log.date)
})
guvnor.on('daemon:log:debug', function(log) {
console.info('guvnor said %s at %s', log.message, log.date)
})