Skip to content

Commit

Permalink
set end on ping
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 1, 2024
1 parent 3edad90 commit 7da3e4a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/com/rultor/agents/aws/PingsInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.jcabi.log.Logger;
import com.jcabi.ssh.Shell;
import com.jcabi.xml.XML;
import com.rultor.Time;
import com.rultor.agents.AbstractAgent;
import com.rultor.agents.shells.TalkShells;
import java.io.IOException;
Expand Down Expand Up @@ -86,11 +87,20 @@ public Iterable<Directive> process(final XML xml) throws IOException {
);
++attempt;
if (attempt > 3) {
dirs.xpath("/talk/daemon").remove();
Logger.warn(
this, "The AWS instance %s is officially dead at %s",
instance, name
);
dirs.xpath("/talk/daemon").strict(1);
if (xml.nodes("/talk/daemon/started").isEmpty()) {
dirs.remove();
Logger.warn(
this, "The AWS instance %s is officially dead at %s (never started)",
instance, name
);
} else {
dirs.add("ended").set(new Time().iso()).up().add("code").set(1);
Logger.warn(
this, "The AWS instance %s is officially dead at %s",
instance, name
);
}
break;
}
new Sleep(1L).now();
Expand Down

0 comments on commit 7da3e4a

Please sign in to comment.