Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge "Clean up existing legacy echo server"
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesalt authored and Gerrit Code Review committed Sep 3, 2012
2 parents 3f14f10 + 1b4764f commit e7e6d5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion dev_setup/cookbooks/echo/recipes/default.rb
Expand Up @@ -16,12 +16,26 @@

bash "Install Echo Server" do
code <<-EOH
if [ -L "/etc/init.d/echoserver" ]; then
service echoserver stop
rm /etc/init.d/echoserver
fi
if [ -d "/tmp/echoserver/" ]; then
rm -rf /tmp/echoserver/
fi
if [ -d #{File.join(node[:echo_server][:path])} ]; then
rm -rf #{File.join(node[:echo_server][:path])}
fi
unzip #{echoserver_tarball_path} -d /tmp
cp -r /tmp/echoserver #{File.join(node[:deployment][:home], 'deploy')}
ln -s -f -t /etc/init.d/ #{File.join(node[:echo_server][:path], 'echoserver')}
EOH
not_if do
::File.exists?(File.join(node[:echo_server][:path], 'echoserver'))
File.symlink?("/etc/init.d/echoserver") and \
(File.join(node[:echo_server][:path], 'echoserver') == File.readlink("/etc/init.d/echoserver"))
end
end

Expand Down
4 changes: 4 additions & 0 deletions dev_setup/cookbooks/echo/templates/default/echoserver.erb
Expand Up @@ -85,6 +85,10 @@ kill_and_wait() {

start_echoserver() {
echo "starting echo server"
lsof -i:<%= node[:echo_server][:port] %> > /dev/null \
&& echo "Port <%= node[:echo_server][:port] %> is not available" \
&& exit 1

java \
-jar $ECHOSEVER_ROOT/lib/EchoServer-0.1.0.jar \
-port <%= node[:echo_server][:port] %> \
Expand Down

0 comments on commit e7e6d5b

Please sign in to comment.