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

Commit

Permalink
Clean up existing legacy echo server
Browse files Browse the repository at this point in the history
When re-running dev_setup script, the existing legacy echo server needs
to be stopped first for it holds the port.The old soft link
"/etc/init.d/echoserver" also needs to be removed or the link to new
echoserver will fail to be created.Besides, the legacy echo server under
both "tmp" directory and "CLOUDFOUNDRY_HOME/.deployments/devbox/deploy"
directory should be cleaned.

Change-Id: I4c58ef2d68d4a37a8a7bd2b8db8c9b7aec236afe
  • Loading branch information
bluesalt committed Aug 31, 2012
1 parent c9abdbb commit 1b4764f
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1b4764f

Please sign in to comment.