Class SockDaemonServer<Request, Response>Abstract

Extend this class to create a SockDaemonService that is used by your daemonScript program to service requests.

Type Parameters

Hierarchy

  • SockDaemonServer

Constructors

Properties

#connectionTimeout: number = 1_000
#daemonScript?: string
#didOnExit: boolean = false
#idleTimeout: number = ...
#idleTimer?: Timeout
#logFile: string
#mtimeFile: string
#name: string
#path: string
#pidFile: string
#server?: Server
#socket: string
#startingLock: StartingLock

Accessors

  • get connectionTimeout(): number
  • Time in milliseconds before a connection will be disconnected if it does not make any requests. Defaults to 1000 (1 second)

    Returns number

  • get idleTimeout(): number
  • Time in milliseconds before the daemon will close if no requests are received. Defaults to 3_600_000 (1 hour)

    Returns number

  • get logFile(): string
  • Path where daemon logs are written

    Returns string

  • get mtimeFile(): string
  • File containing the numeric mtime of the daemon script, so that it can be restarted on change.

    Returns string

  • get path(): string
  • The folder where this daemon service stores stuff

    Returns string

  • get pidFile(): string
  • File containing the daemon process ID

    Returns string

  • get server(): undefined | Server
  • When listening, the net.Server object

    Returns undefined | Server

  • get socket(): string
  • Path to the socket used by this service

    Returns string

  • get serviceName(): string
  • The name of the service. Must match the value set in the SockDaemonClient class that connects to this service.

    Returns string

Methods

  • Parameters

    • n: number = ...

    Returns void

  • Returns Promise<void>

  • Parameters

    • server: Server

    Returns Promise<void>

  • Parameters

    • er: Error

    Returns Promise<void>

  • Parameters

    • n: number

    Returns Promise<void>

  • Returns Promise<void>

  • Stop listening for requests and close the socket.

    Returns void

  • Method that receives Request objects and returns a Response object to be sent over the socket to the client.

    Parameters

    • msg: Request

    Returns Omit<Response, "id"> & {
        id?: string;
    } | Promise<Omit<Response, "id"> & {
        id?: string;
    }>

  • Parameters

    • msg: any

    Returns msg is Request

  • Check if a daemon server is already running for this cwd/name, and if so, gracefully exit. Otherwise, start up the server and write process id to the pidFile

    Returns Promise<void>

Generated using TypeDoc