EC2 remote shutdown
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.
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
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.
Thank you @ecwood. @acevedol do you think you could try that?