Skip to content

infinity.service

Provides functionality for checking and controling operating system services.

Module: infinity.service

Example:

infinity.loadModule('infinity.service');

console.debug(infinity.service.exists('MariaDB'));
console.debug(infinity.service.getStatus('MariaDB'));
console.debug(infinity.service.start('MariaDB', true));
console.debug(infinity.service.stop('Druckwarteschlange', true, true));
console.debug(infinity.service.setStartupType('MariaDB', infinity.service.startupType.autoStart));

Functions

exists()

Returns whether the specified operating system service exists.

Signature:

exists( serviceName: string ): boolean

Parameters:

  • serviceName: string

    The name of the service to be checked.

Return type: boolean

Example:

infinity.loadModule('infinity.service');
if ( infinity.service.exists('MariaDB') ) {
  //...
}

getStatus()

Returns the running status of the operating system service according to status

Signature:

getStatus( serviceName: string ): infinity.service.status

Parameters:

  • serviceName: string

    The name of the service to be checked.

Return type: status

Example:

infinity.loadModule('infinity.service');
let status = infinity.service.getStatus('MariaDB');

setStartupType()

Attempts to alter the startup type of the specified operating system service. Returns a boolean value indicating success or failure.

Signature:

setStartupType( serviceName: string, startupType: infinity.service.startupType ): boolean

Parameters:

  • serviceName: string

    The name of the service to be altered.

  • startupType: startupType

    The startup type to be set according to startupType.

Return type: boolean

Example:

infinity.loadModule('infinity.service');
if ( infinity.service.setStartupType('MariaDB', infinity.service.startupType.autoStart) ) {
  //...
}

start()

Attempts to start the specified operating system service. Returns a boolean value indicating success or failure.

Signature:

start( serviceName: string, waitFor?: boolean ): boolean

Parameters:

  • serviceName: string

    The name of the service to be started.

  • waitFor: boolean, optional

    Whether to wait for the operation to complete.

Return type: boolean

Example:

infinity.loadModule('infinity.service');
if ( infinity.service.start('MariaDB') ) {
  //...
}

stop()

Attempts to stop the specified operating system service. Returns a boolean value indicating success or failure.

Signature:

stop( serviceName: string, waitFor?: boolean, force?: boolean ): boolean

Parameters:

  • serviceName: string

    The name of the service to be stopped.

  • waitFor: boolean, optional

    Whether to wait for the operation to complete.

  • force: boolean, optional

    Whether to attempt a forceful shutdown of the service.

Return type: boolean

Example:

infinity.loadModule('infinity.service');
if ( infinity.service.stop('MariaDB') ) {
  //...
}

Enums

infinity.service.startupType

Values:

  • autoStart: 2

    Stands for the service starting with the operating system.

  • demandStart: 3

    Stands for the service starting on manual demand.

  • disabled: 4

    Stands for a disabled service.

Example:

infinity.loadModule('infinity.service');
let startupType = infinity.service.startupType.autoStart;

infinity.service.status

Values:

  • unknown: 0

    Stands for a status that can't be determined.

  • stopped: 1

    Stands for a stopped service.

  • startPending: 2

    Stands for a service pending to be started.

  • stopPending: 3

    Stands for a service pending to be shut down.

  • running: 4

    Stands for a running service.

  • continuePending: 5

    Stands for a service pending to be continued.

  • pausePending: 6

    Stands for a service pending to be paused.

  • paused: 7

    Stands for a paused service.

Example:

infinity.loadModule('infinity.service');
let status = infinity.service.status.unknown;