Note that there are some explanatory texts on larger screens.

plurals
  1. POChef + custom systemd script
    primarykey
    data
    text
    <p>I have a very basic systemd script for JBoss on Ubuntu 12.04. I am able to run it successfully via "sudo service jboss start" OR "sudo /etc/init.d/jboss start". I can't get this to work with Chef. I would have thought it would be as simple as:</p> <pre><code>service "jboss" do action [ :start ] end </code></pre> <p>But no go. I've tried:</p> <pre><code>service "jboss" do supports :start =&gt; true, :stop =&gt; true, :status =&gt; false action [ :start, :enable ] start_command "sudo /etc/init.d/jboss start" end </code></pre> <p>and different permutations as well.</p> <p>Thanks for your help, and see below for my systemd script.</p> <pre><code>#!/bin/bash ### BEGIN INIT INFO # Provides: jboss # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop JBoss AS v7.0.0 # Usage: this file neeed to be renamed jboss ### END INIT INFO # #source some script files in order to set and export environmental variables #as well as add the appropriate executables to $PATH [ -r /etc/profile.d/java.sh ] &amp;&amp; . /etc/profile.d/java.sh [ -r /etc/profile.d/jboss.sh ] &amp;&amp; . /etc/profile.d/jboss.sh case "$1" in start) echo "Starting JBoss AS 7.1.1" cd /home/jboss/jboss-as-7.1.1.Final/bin/ sudo -u jboss ./standalone.sh &amp; ;; stop) echo "Stopping JBoss AS 7.1.1" sudo -u jboss /home/jboss/jboss-as-7.1.1.Final/bin/jboss-cli.sh --connect command=:shutdown #JBOSS_PID=$(ps -ef | grep jboss-as-7.1.1.Final | grep -v grep | awk '{print $2}') #kill -15 $JBOSS_PID #echo "Sig term sent" #echo "Terminating all ml_process" #pkill -9 ml_server ;; *) echo "Usage: /etc/init.d/jboss {start|stop}" exit 1 ;; esac </code></pre> <p><strong>UPDATE</strong>: </p> <p>Thanks to those who replied. I managed to make a bit of progress. I downloaded the JBoss Chef recipe from OpsCode: <a href="http://community.opscode.com/cookbooks/jboss" rel="nofollow">http://community.opscode.com/cookbooks/jboss</a></p> <p>Turns out that the JAVA_HOME environmental variable wasn't being set in my script. I'm now using the startup script from OpsCode. JBoss now starts with the recipe:</p> <pre><code>service "jboss" do action [ :enable, :start ] end </code></pre> <p>But Chef hangs on this line. I think it's waiting for JBoss to "finish", but since it's supposed to be a service it should persistent. If I SSH into the instance and kill JBoss, the Chef recipe completes successfully. How can I get the Chef recipe to end normally? See below for my updated systemd script.</p> <pre><code>#!/bin/sh ### BEGIN INIT INFO # Provides: jboss # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop JBoss AS v7.0.0 ### END INIT INFO export JAVA_HOME=/usr/lib/jvm/java-7-oracle #define where jboss is - this is the directory containing directories log, bin, conf etc export JBOSS_HOME=${JBOSS_HOME:-"/home/jboss/jboss-as-7.1.1.Final"} #define the user under which jboss will run, or use 'RUNASIS' to run as the current user export JBOSS_USER=${JBOSS_USER:-"jboss"} #make sure java is in your path JAVAPTH=${JAVAPTH:-"$JAVA_HOME/bin/java"} export PATH=$PATH:$JAVAPTH #source some script files in order to set and export environmental #variables #as well as add the appropriate executables to $PATH [ -r /etc/profile.d/java.sh ] &amp;&amp; . /etc/profile.d/java.sh [ -r /etc/profile.d/jboss.sh ] &amp;&amp; . /etc/profile.d/jboss.sh case "$1" in start) echo "Starting JBoss AS 7.0.0" cd /home/jboss/jboss-as-7.1.1.Final/bin/ sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh ;; stop) echo "Stopping JBoss AS 7.0.0" sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown ;; *) echo "Usage: /etc/init.d/jboss {start|stop}" exit 1 ;; esac exit 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload