Class: Daemon

servers/daemon~ Daemon

Server for unix socket clients, i.e. command line interface

new Daemon(app, config, logger)

Create the service
Parameters:
Name Type Description
app App Application
config object Configuration
logger Logger Logger service

Members


<static> provides :string

Service name is 'servers.daemon'
Type:
  • string

<static> requires :Array.<string>

Dependencies as constructor arguments
Type:
  • Array.<string>

<static> requestTimeout :number

How much time to wait for tracker response
Type:
  • number

Methods


<async> init(name)

Initialize the server
Parameters:
Name Type Description
name string Config section name
Returns:
Type
Promise

<async> start(name)

Start the server
Parameters:
Name Type Description
name string Config section name
Returns:
Type
Promise

<async> stop(name)

Stop the server
Parameters:
Name Type Description
name string Config section name
Returns:
Type
Promise

send(id, data)

Send message
Parameters:
Name Type Description
id string Client ID
data Buffer | null Data to send

onServerError(error)

Server error handler
Parameters:
Name Type Description
error object The error

onListening()

Server listening event handler

onConnection(socket)

Connection handler
Parameters:
Name Type Description
socket object Client socket

onMessage(id, data)

Client message handler
Parameters:
Name Type Description
id string Client ID
data Buffer Message
Returns:
Destroy socket on false
Type
boolean

onError(id, error)

Client error handler
Parameters:
Name Type Description
id string Client ID
error Error Error

onClose(id)

Client disconnect handler
Parameters:
Name Type Description
id string Client ID