Hi,

I've been using jclouds ScriptBuilder and SshClient to run scripts on nodes 
I've created with jclouds. Everything runs correctly, except when the last 
command is "service start" the service gets killed on ssh disconnect, and I see 
the message "node app stopped but pid file exists" when I ssh into the machine 
and check the status of the service. However, adding an additional line to the 
end of the script of "service status" prevents the service from being stopped. 
Why is this? On a side note, appending anything other than "service status" 
(for example, "true") does not have the same effect.

Any insight as to why this is happening? Is this a deliberate implementation 
decision? Is there a better way around this?

Here's the script I'm running, for reference, where hatjitsu is an open source 
planning poker node app:

mv /tmp/hatjitsu /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/hatjitsu
yum -y install git
curl -sL https://rpm.nodesource.com/setup | bash -
yum -y install nodejs
mkdir -p /var/www/hatjitsu
cd /var/www/norbjitsu; npm install richarcher/Hatjitsu
chkconfig --add hatjitsu
chmod +x /etc/init.d/hatjitsu
service hatjitsu start
# prevent the service from being stopped on ssh disconnect
service hatjitsu status

Java code to run the script:

LoginCredentials login = 
LoginCredentials.builder().user("root").privateKey(privateKey).build();

SshClient client = 
compute.getContext().utils().sshForNode().apply(NodeMetadataBuilder.fromNodeMetadata(md)
                .credentials(login).build());

ScriptBuilder scriptBuilder = new ScriptBuilder();
for (String s : sshCmds) {
            scriptBuilder.addStatement(Statements.exec(s));
}
String script = scriptBuilder.render(OsFamily.UNIX);
client.exec(script);

Thanks for any insight you can provide,

Ashley Kasim

Reply via email to