Skip to content

[Windows] Agent silently hangs forever if hook script doesn't close STDOUT #288

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

Closed
moloch-- opened this issue Jun 20, 2021 · 5 comments
Closed

Comments

@moloch--
Copy link

moloch-- commented Jun 20, 2021

On Windows I need the CodeDeploy Agent to simply start a plain .exe (non-service) process on the server for the ApplicationStart, but this does not seem to be possible. It seems to be related to how the Agent runs the deployment scripts, similar issues here.

However, the problem doesn't seem to have ever been fixed, and the only workarounds I can find are for Linux (the AWS documentation also only provides work around examples for Linux).

I have a script that invokes the server process in what should be a non-blocking way, it works fine when running the script from the command line:

start.bat

start C:\server.exe

Output:

Script at specified location: scripts/start.bat failed to close STDOUT

I've also tried these but they don't work:

cmd.exe /c "start C:\server.exe"
start C:\server.exe 2>NUL

What's really annoying is that the process gets created but the Agent still reports the deployment as a failure.

@hashitha
Copy link

I have run in to the same issue, any updates on this?

@moloch--
Copy link
Author

I developed a workaround using PowerShell, as far as I know this bug has not been fixed:

powershell.exe Start-Process -WorkingDirectory C:\ -FilePath C:\foo.exe

@philstrong
Copy link
Contributor

@hashitha
Copy link

This is what worked for me

create a script name start.ps1
with the following contents
Start-Process -FilePath "C:\QUBS\server\Server.exe"

also for some reason, this only works if I invoke using command line
e.g. aw deploy create-deployment --application-name ...

Just another note:
If I use AWS Pipeline then it fails like 90% of the time and only works if I clear the temp files of AWS deploy %Programdata% then restart the EC2 machine. I was using Windows 2022 server. Maybe this is not supported yet

@mwjones-aws
Copy link
Contributor

Closing as not planned.

You need to start your application in a process other than the one CodeDeploy is using to run your hook script. Start-Process accomplishes this. You can also install your application as a service.

@mwjones-aws mwjones-aws closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants