RTX-KG2 icon indicating copy to clipboard operation
RTX-KG2 copied to clipboard

EC2 remote shutdown

Open acevedol opened this issue 3 years ago • 3 comments

Building KG2 often finishes or crashes at odd times when I am unable to check on it for a few hours, leading to unnecessary run time on the instance that is charged per hour. This is not ideal. I want to implement a remote shut down process as part of Snakemake so that when the build shuts down for any reason, it sends a shut down signal so we don't waste so much time on the server.

AWS CLI has a command stop-instances that I believe is what I'm looking for.

So it might look like: aws ec2 stop-instances --instance-id <value>

I'm not sure how to incorporate it. Should it go in Snakefile-finish or its own rule? Elsewhere? I'll run some tests to figure that part out.

acevedol avatar May 10 '22 16:05 acevedol

I think this can be done without modifying Snakemake. If your Bash command to run the build is CMD1, then inside your screen session:

CMD1; aws ec2 stop-instances --instance-id i-03e415099e4be5409

saramsey avatar Jun 10 '22 21:06 saramsey

I once tried to set up something to email me when the Snakefile finished. It didn't work great, since anytime you are emailing from AWS, it goes to spam (and also, setting up the mail tools was more manual that we want). However, through this process, I learned how to make things happen on error (or success). Here is how to do it:

https://github.com/RTXteam/RTX-KG2/blob/fab3a329882164cf945a70255968989bfbad492d/Snakefile#L162-L165

We can add this to the end of Snakefile-finish, so that it is at the end of the Snakefile, as desired.

ecwood avatar Jun 28 '23 04:06 ecwood

Thank you @ecwood. @acevedol do you think you could try that?

saramsey avatar Sep 23 '23 03:09 saramsey