Skip to content

Commit

Permalink
kill daemon on dismount
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 19, 2024
1 parent e928119 commit f132691
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
23 changes: 1 addition & 22 deletions src/main/java/com/rultor/agents/daemons/DismountDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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 All @@ -42,7 +41,6 @@
import lombok.ToString;
import org.xembly.Directive;
import org.xembly.Directives;
import org.xembly.Xembler;

/**
* Marks the daemon as done when the host is not reachable and the
Expand Down Expand Up @@ -100,28 +98,9 @@ public Iterable<Directive> process(final XML xml) throws IOException {
);
dirs.append(
new Directives()
.xpath("/talk/daemon/ended").remove()
.xpath("/talk/daemon/code").remove()
.xpath("/talk/daemon/tail").remove()
.xpath("/talk/daemon")
.strict(1)
.add("ended").set(new Time().iso()).up()
.add("code").set("1").up()
.add("tail").set(
Xembler.escape(
String.join(
"\n",
String.format(
"The host %s is not reachable",
DismountDaemon.host(xml)
),
"The daemon is older than a few days",
"The daemon is marked as done",
ex.getMessage(),
"Please, try to run the daemon again"
)
)
)
.remove()
);
}
return dirs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public final class SanitizesDaemon extends AbstractAgent {
* Ctor.
*/
public SanitizesDaemon() {
super("/talk/daemon[dir]");
super("/talk/daemon[dir and not(ended)]");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ void endsIfHostNotFound() throws IOException {
"Daemon should be stopped for not found host",
talk.read(),
XhtmlMatchers.hasXPaths(
"/talk/daemon/ended",
"/talk/daemon/tail"
"/talk[not(daemon)]"
)
);
}
Expand Down

0 comments on commit f132691

Please sign in to comment.