Leverege Platform

Leverege Platform

  • Overview
  • JSDocs
  • REST API
  • Help

›JSDoc

JSDoc

  • Home
  • API Server
  • API Attributes
  • Api Patch Ops
  • API Redux
  • Array Util
  • Base62 Util
  • Cache
  • Cluster Manager
  • Data Store
  • Exit
  • Factory
  • Limit
  • Lock
  • Message Queue
  • Messages
  • Path
  • Permissions
  • Reasoner
  • String Util
  • UI Active Theme
  • UI Elements
  • UI Linear View Elements
  • UI Mapbox Elements
  • Validator

Exit

Functions

init(opts)

Initializes the Exit parameters

add(callback, [eventType])

Adds a callback to the exit hooks. These will be called to allow graceful clean up of resources in an asynchronous way.

remove(callback)

Removes a callback from the hooks

callbacks([eventType], all)

Returns a new array containing the callbacks

onUnhandledRejection()

A shortcut for add( callback, 'unhandledRejection' )

onUncaughtException()

A shortcut for add( callback, 'uncaughtException' )

setExitTimeout()

Sets the max time in milliseconds to wait before an exit is forced

getExitTimeout()

Returns the max time in milliseconds to wait before an exit is forced

setExitDelay()

Sets the time in milliseconds to delay after hooks have finsihed before calling exit

getExitDelay()

Gets the time in milliseconds to delay after hooks have finsihed before calling exit

setExit()

Sets the exit function. For testing purposes.

getExit()

Gets the exit function

setExitCancelled()

Sets the exit cancelled function. For testing purposes. Invoked when an event has been filtered

getExitCancelled()

Gets the exit cancelled function

unhandle(eventType)

Removes listeners from handling the event of the given type

handle(eventType, exitCode, opts)

Causes Exit to exit when the event type is received.

handleErr(eventType, exitCode, opts)

Causes Exit to exit when the event type is received. It is treated as an error.

handlers() ⇒ object

Returns the installed handlers

addFilter(eventType, filter)

Add a filter for the given event type. A filter can be installed to stop an exit from occuring. Filters are run before and shutdown hooks.

removeFilter(eventType, exitCode) ⇒ boolean

Causes Exit to exit when the event type is received.

filters(eventType) ⇒ object | array

Returns the current filters

exit(code)

Request a graceful exit

installDefaultHandlers()

Installs default signal handlers for SIGINT, SIGHUP, SIGTERM and SIGBREAK. This will also install uncaughtException and unhandledRejection exceptions

init(opts)

Initializes the Exit parameters

Kind: global function

ParamTypeDescription
optsobjectoptions to set
opts.timeoutint(20000) sets the time in ms to exit event if callbacks havent completed
opts.exitDelayint(100) sets the time in ms to delay after callbacks have completed before calling exit
opts.exitfunctionif set, this will be called instead of process.exit(). For testing
opts.exitCancelledfunctionif set, this will be called when a filter cancels an exit. For testing

add(callback, [eventType])

Adds a callback to the exit hooks. These will be called to allow graceful clean up of resources in an asynchronous way.

Kind: global function

ParamTypeDescription
callbackfunctionthis function( err, { eventType, code } ) should return a Promise.
[eventType]stringthe type to trigger. if this undefined/null, the callback will be triggered for all types. This is mainly used to register callbacks against 'uncaughtException' or 'unhandledRejection'

remove(callback)

Removes a callback from the hooks

Kind: global function

ParamTypeDescription
callbackfunctionthe function to remove

callbacks([eventType], all)

Returns a new array containing the callbacks

Kind: global function

ParamTypeDescription
[eventType]stringif supplied, this will return only the callbacks specifically registered for the eventType.
allbooleanif true, then both the specific and general call backs are returned

onUnhandledRejection()

A shortcut for add( callback, 'unhandledRejection' )

Kind: global function

onUncaughtException()

A shortcut for add( callback, 'uncaughtException' )

Kind: global function

setExitTimeout()

Sets the max time in milliseconds to wait before an exit is forced

Kind: global function

getExitTimeout()

Returns the max time in milliseconds to wait before an exit is forced

Kind: global function

setExitDelay()

Sets the time in milliseconds to delay after hooks have finsihed before calling exit

Kind: global function

getExitDelay()

Gets the time in milliseconds to delay after hooks have finsihed before calling exit

Kind: global function

setExit()

Sets the exit function. For testing purposes.

Kind: global function

getExit()

Gets the exit function

Kind: global function

setExitCancelled()

Sets the exit cancelled function. For testing purposes. Invoked when an event has been filtered

Kind: global function

getExitCancelled()

Gets the exit cancelled function

Kind: global function

unhandle(eventType)

Removes listeners from handling the event of the given type

Kind: global function

ParamTypeDescription
eventTypestringthe event type to stop listening to.

handle(eventType, exitCode, opts)

Causes Exit to exit when the event type is received.

Kind: global function

ParamTypeDescription
eventTypestringthe type of event to listen for
exitCodeintthe exit code
optsobject

handleErr(eventType, exitCode, opts)

Causes Exit to exit when the event type is received. It is treated as an error.

Kind: global function

ParamTypeDescription
eventTypestringthe type of event to listen for
exitCodeintthe exit code
optsobject

handlers() ⇒ object

Returns the installed handlers

Kind: global function
Returns: object - the installed handlers

addFilter(eventType, filter)

Add a filter for the given event type. A filter can be installed to stop an exit from occuring. Filters are run before and shutdown hooks.

Kind: global function

ParamTypeDescription
eventTypestringthe type to filter
filterfunctionthis function will be given the arguments of the event. If it returns true, the exit will not occur

removeFilter(eventType, exitCode) ⇒ boolean

Causes Exit to exit when the event type is received.

Kind: global function
Returns: boolean - true if the filter was removed

ParamTypeDescription
eventTypestringthe type of event to listen for
exitCodeintthe exit code

filters(eventType) ⇒ object | array

Returns the current filters

Kind: global function
Returns: object | array - if eventType is null, an object of eventType : Array will be returned. Otherwise, an array (possibly empty) will be returned.

ParamTypeDescription
eventTypestringthe type of filters. If null, all will be returned

exit(code)

Request a graceful exit

Kind: global function

ParamTypeDescription
codeintthe exit code to use, defaults to zero.

installDefaultHandlers()

Installs default signal handlers for SIGINT, SIGHUP, SIGTERM and SIGBREAK. This will also install uncaughtException and unhandledRejection exceptions

Kind: global function

← Data StoreFactory →
  • Functions
  • init(opts)
  • add(callback, [eventType])
  • remove(callback)
  • callbacks([eventType], all)
  • onUnhandledRejection()
  • onUncaughtException()
  • setExitTimeout()
  • getExitTimeout()
  • setExitDelay()
  • getExitDelay()
  • setExit()
  • getExit()
  • setExitCancelled()
  • getExitCancelled()
  • unhandle(eventType)
  • handle(eventType, exitCode, opts)
  • handleErr(eventType, exitCode, opts)
  • handlers() ⇒ object
  • addFilter(eventType, filter)
  • removeFilter(eventType, exitCode) ⇒ boolean
  • filters(eventType) ⇒ object | array
  • exit(code)
  • installDefaultHandlers()
Leverege Platform
Docs
Overview
Connect
FacebookLinkedInTwitter
Facebook Open Source