kirillkovalenko / nssm

Non-Sucking Service Manager
https://nssm.cc
736 stars 126 forks source link

Forward NSSM_ hook enviroment variables to the service command #21

Closed betonetotbo closed 4 years ago

betonetotbo commented 4 years ago

I need to access information about the NSSM parameters from my application, and would be nice to have the same NSSM environment variables passed for hooks in the main application.

This is a nice feature, for example, to my application to known the NSSM_SERVICE_NAME, to my application to be able to perform a service restart of itself.

This variables (tooked from README.md):

NSSM_EXE - Path to NSSM itself.
  NSSM_CONFIGURATION - Build information for the NSSM executable,
    eg 64-bit debug.
  NSSM_VERSION - Version of the NSSM executable.
  NSSM_BUILD_DATE - Build date of NSSM.
  NSSM_PID - Process ID of the running NSSM executable.
  NSSM_DEADLINE - Deadline number of milliseconds after which NSSM will
    kill the hook if it is still running.
  NSSM_SERVICE_NAME - Name of the service controlled by NSSM.
  NSSM_SERVICE_DISPLAYNAME - Display name of the service.
  NSSM_COMMAND_LINE - Command line used to launch the application.
  NSSM_APPLICATION_PID - Process ID of the primary application process.
    May be blank if the process is not running.
  NSSM_EVENT - Event class triggering the hook.
  NSSM_ACTION - Event action triggering the hook.
  NSSM_TRIGGER - Service control triggering the hook.  May be blank if
    the hook was not triggered by a service control, eg Exit/Post.
  NSSM_LAST_CONTROL - Last service control handled by NSSM.
  NSSM_START_REQUESTED_COUNT - Number of times the application was
    requested to start.
  NSSM_START_COUNT - Number of times the application successfully started.
  NSSM_THROTTLE_COUNT - Number of times the application ran for less than
    the throttle period.  Reset to zero on successful start or when the
    service is explicitly unpaused.
  NSSM_EXIT_COUNT - Number of times the application exited.
  NSSM_EXITCODE - Exit code of the application.  May be blank if the
    application is still running or has not started yet.
  NSSM_RUNTIME - Number of milliseconds for which the NSSM executable has
    been running.
  NSSM_APPLICATION_RUNTIME - Number of milliseconds for which the
    application has been running since it was last started.  May be blank
    if the application has not been started yet.
kirillkovalenko commented 4 years ago

THIS REPO IS NOT OWNED OR MONITORED BY THE AUTHOR OF THIS APPLICATION! REACH OUT TO HIM AT me@iain.cx