Skip to content

Commit

Permalink
ark works reliably on rhel6
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwb committed Feb 13, 2012
1 parent 80cf639 commit 65e355b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
4 changes: 2 additions & 2 deletions java/providers/ark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def parse_app_dir_name url

unless ::File.exists?(app_root)
FileUtils.mkdir app_root, :mode => new_resource.app_home_mode
FileUtils.chown new_resource.owner, new_resource.owner, app_root
end

r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do
Expand Down Expand Up @@ -101,7 +100,8 @@ def parse_app_dir_name url
).run_command
unless cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ Command \' mv "#{tmpdir}/#{app_dir_name}" "#{app_dir}" \' failed ])
end
end
FileUtils.chown_R new_resource.owner, new_resource.owner, app_dir
FileUtils.rm_r tmpdir
new_resource.updated_by_last_action(true)
end
Expand Down
4 changes: 2 additions & 2 deletions tomcat/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
version = node["tomcat"]["version"]
default["tomcat"]["prefix_dir"] = "/usr/local"
prefix_dir = node["tomcat"]["prefix_dir"]
default["tomcat"]["home"] = "#{prefix_dir}/tomcat/tomcat#{version}"
default["tomcat"]["base"] = "#{prefix_dir}/tomcat/tomcat#{version}"
default["tomcat"]["home"] = "#{prefix_dir}/tomcat/default"
default["tomcat"]["base"] = "#{prefix_dir}/tomcat/default"
tomcat_base = node["tomcat"]["base"]
default["tomcat"]["context_dir"] = "#{tomcat_base}/conf/Catalina/localhost"
default["tomcat"]["log_dir"] = "#{tomcat_base}/logs"
Expand Down
28 changes: 16 additions & 12 deletions tomcat/recipes/ark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,38 @@
distro = "el"
end

user node['tomcat']['user']

java_ark "tomcat#{version}" do
url node['tomcat'][version]['url']
checksum node['tomcat'][version]['checksum']
app_home "#{node['tomcat']['prefix_dir']}/tomcat/default"
app_home "#{node['tomcat']['home']}"
owner node['tomcat']['user']
end

service "tomcat" do
service_name "tomcat#{version}"
supports :restart => true, :reload => true, :status => true
action [:enable, :start]
end

template "tomcat#{version}" do
t_init = template "tomcat#{version}" do
path "/etc/init.d/tomcat#{version}"
source "tomcat.init.#{distro}.erb"
owner "root"
group "root"
mode "0774"
variables( :name => "tomcat#{version}")
notifies :restart, resources(:service => "tomcat")
end


template "/etc/default/tomcat#{version}" do
t_default = template "/etc/default/tomcat#{version}" do
source "default_tomcat.erb"
owner "root"
group "root"
mode "0644"
notifies :restart, resources(:service => "tomcat")
end

service "tomcat" do
service_name "tomcat#{version}"
supports :restart => true, :reload => true, :status => true
action [:enable, :start]
end

# we can't notify a service until after it has been created
t_init.notifies :restart, resources(:service => "tomcat")
t_default.notifies :restart, resources(:service => "tomcat")

2 changes: 2 additions & 0 deletions tomcat/recipes/ark_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
distro = "el"
end

user node['tomcat']['user']

java_ark "tomcat#{version}" do
url node['tomcat'][version]['url']
checksum node['tomcat'][version]['checksum']
Expand Down
1 change: 1 addition & 0 deletions tomcat/templates/default/default_tomcat.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TOMCAT_GROUP=<%= node["tomcat"]["group"] %>
JAVA_HOME=<%= node["java"]["java_home"] %>
CATALINA_HOME=<%= node["tomcat"]["home"] %>
CATALINA_BASE=<%= node["tomcat"]["base"] %>
CATALINA_PID="/var/run/tomcat<%= node["tomcat"]["version"] %>.pid"
JAVA_OPTS="<%= node["tomcat"]["jvm_opts"] +
node["tomcat"]["jmx_opts"] +
node["tomcat"]["webapp_opts"] +
Expand Down
4 changes: 3 additions & 1 deletion tomcat/templates/default/tomcat.init.debian.erb
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ case "$1" in
echo "// AUTO-GENERATED FILE from /etc/tomcat7/policy.d/" \
> "$POLICY_CACHE"
echo "" >> "$POLICY_CACHE"
cat $CATALINA_BASE/conf/policy.d/*.policy \
if [ -d $CATALINA_BASE/conf/policy.d ] ; then
cat $CATALINA_BASE/conf/policy.d/*.policy \
>> "$POLICY_CACHE"
fi

# Remove / recreate JVM_TMP directory
rm -rf "$JVM_TMP"
Expand Down
12 changes: 6 additions & 6 deletions tomcat/templates/default/tomcat.init.el.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# - init system Bryan W. Berry (<[email protected]>)
#

#
# Source LSB function library.
if [ -r /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
Expand Down Expand Up @@ -105,7 +106,7 @@ fi
if [ $have_tty -eq 1 ]; then
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
echo "Using CATALINA_TMPDIR: $JVM_TMP"
if [ "$1" = "debug" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
Expand All @@ -130,18 +131,17 @@ function start() {
touch "$CATALINA_PID"
chown "$TOMCAT_USER":"$TOMCAT_USER" "$CATALINA_PID"
run_java_cmd=$(cat <<EOF
"$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS $CATALINA_OPTS \
"$_RUNJAVA" "$LOGGING_CONFIG" $JAVA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
-Djava.io.tmpdir="$JVM_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 &
echo \$! > "$CATALINA_PID"
EOF
)


pushd $INVOKE_PATH 2>&1 > /dev/null
$SU "$TOMCAT_USER" -c "$run_java_cmd"
popd 2>&1 > /dev/null
Expand All @@ -159,8 +159,8 @@ function stop() {
exit 1
fi
else
echo "\$CATALINA_PID was set ($CATALINA_PID) but the specified file does not exist. Is Tomcat running? Stop aborted."
exit 1
echo "\$CATALINA_PID was set ($CATALINA_PID) but the specified file does not exist. Is Tomcat running? Assuming it has stopped and proceeding."
return 0
fi
fi
stop_java_cmd=$(cat <<EOF
Expand Down

0 comments on commit 65e355b

Please sign in to comment.