NetDocuments-Archive / rd-winrm-plugin

Allows rundeck to execute commands with powershell
Apache License 2.0
31 stars 19 forks source link

Unable to keep remote .exe executing after winrm session has ended #55

Open mlamutt opened 6 years ago

mlamutt commented 6 years ago

Hello,

I have run into an issue after upgrading to 1.7.0, where I am using the winrm plugin to run an install.exe file on a remote windows server. The install.exe is spawned and then the winrm session closes, at which point the install.exe session also is terminated. This behavior is not seen on the 1.5.1 version.

I found that if I added a wait after the install.exe is spawned, the exe will complete successfully.

Running this script step fails:

  wget "http://software.prod.net/drone/DroneInstaller-v@option.DroneVersion@.exe" -outfile 
"c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe"

  c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe

Running this script step is successful:

  wget "http://software.prod.net/drone/DroneInstaller-v@option.DroneVersion@.exe" -outfile 
"c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe"

  c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe
  wait 30

Running this script step is also successful:

  wget "http://software.prod.net/drone/DroneInstaller-v@option.DroneVersion@.exe" -outfile 
"c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe"

  cmd /c "c:\build\drone\DroneInstaller-v@option.DroneVersion@.exe"

if I set the wait to 10 seconds I can watch the process page and see both the winrm and exe sessions terminate at the same time. I have also tried to force the exe to install silently, without any change in behavior.

any ideas on why this behavior changed between the versions?

UnicodeTreason commented 6 years ago

Hrmm no specific changes to the script should have modified that behaviour that I can see. It's possible the updated gems we are using are little better at closing sessions than before or something.

If you run the installer via PowerShell you should be able to make your script -Wait for the process to finish before continuing.