Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_nssm: Configure NSSM to preserve log files on service restart/crash #536

Open
drfuzzyness opened this issue Oct 3, 2023 · 1 comment

Comments

@drfuzzyness
Copy link

drfuzzyness commented Oct 3, 2023

SUMMARY

It would be helpful if the community.windows.win_nssm module can expose NSSM's AppStdoutCreationDisposition and AppStderrCreationDisposition properties so that logs can be preserved when a service restarts. See "File Rotation Tab" on the NSSM usage page for a small amount of extra information.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.windows.win_nssm

ADDITIONAL INFORMATION

This would pass an integer (2 or 4 are known valid options) directly to NSSM's service configuration. AppStdoutCreationDisposition and AppStderrCreationDisposition can be set independently, but follow similar logic. They should default to the current behavior of setting the -value to 2 (replace log files on restart).

Current behavior:

Update-NssmServiceParameter -parameter "AppStdoutCreationDisposition" -value 2 @common_params
Update-NssmServiceParameter -parameter "AppStderrCreationDisposition" -value 2 @common_params

Proposed configuration example:

tasks:
  - name: My Service
    community.windows.win_nssm:
      name: MyNssmService
      display_name: My NSSM Service
      application: C:\MyFolder\MyExecutable.exe
      app_directory: C:\MyFolder\
      arguments: --silent
      stdout_file: C:\MyFolder\Logs\stdout.log
      stderr_file: C:\MyFolder\Logs\stderr.log
      app_rotate_online: 1
      app_stdout_creation_disposition: 2 # replace file on every service restart
      app_stderr_creation_disposition: 4 # append to file instead of deleting file
      state: restarted
      app_environment:
        PORT: 3001
@drfuzzyness drfuzzyness changed the title Allow configuring NSSM to preserve log files on service restart/crash win_nssm: Configure NSSM to preserve log files on service restart/crash Oct 16, 2023
@jamesdoran
Copy link

+1 for this suggestion please. I'm using nssm to install hashicorp vault agent which requires redirection of stdout and stderr to get logging. If the service crashes and restarts, the previous logs are lost which makes debugging very hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants