Skip to content

Commit

Permalink
Merge remote branch 'nirvdrum/master' into pull
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Conway committed Nov 10, 2009
2 parents de6bb9a + a62955f commit b902618
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 22 deletions.
27 changes: 7 additions & 20 deletions generators/vulcanize/templates/base/config/rubber/deploy-setup.rb
Expand Up @@ -46,26 +46,13 @@
ENDSCRIPT
end

# git in ubuntu 7.0.4 is very out of date and doesn't work well with capistrano
after "rubber:install_packages", "rubber:base:install_git" if scm == "git"
task :install_git do
rubber.run_script 'install_git', <<-ENDSCRIPT
if ! git --version &> /dev/null; then
arch=`uname -m`
if [ "$arch" = "x86_64" ]; then
src="http://mirrors.kernel.org/ubuntu/pool/main/g/git-core/git-core_1.5.4.5-1~dapper1_amd64.deb"
else
src="http://mirrors.kernel.org/ubuntu/pool/main/g/git-core/git-core_1.5.4.5-1~dapper1_i386.deb"
fi
apt-get install liberror-perl libdigest-sha1-perl
wget -qO /tmp/git.deb ${src}
dpkg -i /tmp/git.deb
if [[ "#{repository}" =~ "@" ]]; then
# Get host key for src machine to prevent ssh from failing
rm -f ~/.ssh/known_hosts
! ssh -o 'StrictHostKeyChecking=no' #{repository.gsub(/:.*/, '')} &> /dev/null
fi
after "rubber:install_packages", "rubber:base:configure_git" if scm == "git"
task :configure_git do
rubber.run_script 'configure_git', <<-ENDSCRIPT
if [[ "#{repository}" =~ "@" ]]; then
# Get host key for src machine to prevent ssh from failing
rm -f ~/.ssh/known_hosts
! ssh -o 'StrictHostKeyChecking=no' #{repository.gsub(/:.*/, '')} &> /dev/null
fi
ENDSCRIPT
end
Expand Down
Expand Up @@ -127,7 +127,7 @@ ruby_prefix: "#{use_enterprise_ruby ? '/usr/local' : '/usr'}"
# OPTIONAL: The packages to install on all instances
# You can install a specific version of a package by using a sub-array of pkg, version
# For example, packages: [[rake, 0.7.1], irb]
packages: [postfix, build-essential, ruby-full, ruby1.8-dev, rake, irb]
packages: [postfix, build-essential, ruby-full, ruby1.8-dev, rake, irb, git-core]

# OPTIONAL: gem sources to setup for rubygems
gemsources: ["http://gemcutter.org", "http://gems.rubyforge.org/", "http://gems.github.com"]
Expand Down
56 changes: 56 additions & 0 deletions generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb
@@ -0,0 +1,56 @@

namespace :rubber do

namespace :jetty do

rubber.allow_optional_tasks(self)

after "rubber:install_packages", "rubber:jetty:custom_install"

task :custom_install, :roles => :jetty do
rubber.sudo_script 'install_jetty', <<-ENDSCRIPT
if [[ -z `ls #{rubber_env.jetty_dir} 2> /dev/null` ]]; then
wget -q http://ftp.osuosl.org/pub/eclipse/jetty/#{rubber_env.jetty_version}/dist/jetty-distribution-#{rubber_env.jetty_version}.tar.gz
tar -zxf jetty-distribution-#{rubber_env.jetty_version}.tar.gz
# Install to appropriate location.
mv jetty-distribution-#{rubber_env.jetty_version} #{rubber_env.jetty_prefix}
ln -s #{rubber_env.jetty_prefix}/jetty-distribution-#{rubber_env.jetty_version} #{rubber_env.jetty_dir}
chmod 744 #{rubber_env.jetty_dir}/bin/*.sh
# Cleanup the jetty distribution
rm #{rubber_env.jetty_dir}/webapps/*
rm -r #{rubber_env.jetty_dir}/contexts/test.d/
mv #{rubber_env.jetty_dir}/contexts/demo.xml #{rubber_env.jetty_dir}/contexts/demo.xml.example
mv #{rubber_env.jetty_dir}/contexts/javadoc.xml #{rubber_env.jetty_dir}/contexts/javadoc.xml.example
# Cleanup after ourselves.
rm jetty-distribution-#{rubber_env.jetty_version}.tar.gz
fi
ENDSCRIPT
end

after "rubber:setup_app_permissions", "rubber:jetty:setup_jetty_permissions"

task :setup_jetty_permissions, :roles => :jetty do
run "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{rubber_env.jetty_dir}"
end

before "deploy:stop", "rubber:jetty:stop"
after "deploy:start", "rubber:jetty:start"
after "deploy:restart", "rubber:jetty:restart"

task :restart, :roles => :jetty do
run "#{rubber_env.jetty_dir}/bin/jetty.sh restart"
end

task :stop, :roles => :jetty do
run "#{rubber_env.jetty_dir}/bin/jetty.sh stop"
end

task :start, :roles => :jetty do
run "#{rubber_env.jetty_dir}/bin/jetty.sh start"
end

end
end
@@ -0,0 +1,199 @@
<%-
@path = "#{rubber_env.jetty_dir}/etc/jetty.xml"
%><?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
<!-- -->
<!-- =============================================================== -->


<Configure id="Server" class="org.eclipse.jetty.server.Server">

<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default queued blocking threadpool
-->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
</New>

<!-- Optional Java 5 bounded threadpool with job queue
<New class="org.eclipse.thread.concurrent.ThreadPool">
<Set name="corePoolSize">50</Set>
<Set name="maximumPoolSize">50</Set>
</New>
-->
</Set>



<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->

<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="<%= rubber_env.jetty_port %>"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- To add a HTTPS SSL connector -->
<!-- mixin jetty-ssl.xml: -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- To add a HTTP blocking connector -->
<!-- mixin jetty-bio.xml: -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-bio.xml -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- To allow Jetty to be started from xinetd -->
<!-- mixin jetty-xinetd.xml: -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-xinetd.xml -->
<!-- -->
<!-- See jetty-xinetd.xml for further instructions. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>

<!-- =========================================================== -->
<!-- Configure the context deployer -->
<!-- A context deployer will deploy contexts described in -->
<!-- configuration files discovered in a directory. -->
<!-- The configuration directory can be scanned for hot -->
<!-- deployments at the configured scanInterval. -->
<!-- -->
<!-- This deployer is configured to deploy contexts configured -->
<!-- in the $JETTY_HOME/contexts directory -->
<!-- -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.deploy.ContextDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
<Set name="scanInterval">5</Set>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
</Call>
</New>
</Arg>
</Call>

<!-- =========================================================== -->
<!-- Configure the webapp deployer. -->
<!-- A webapp deployer will deploy standard webapps discovered -->
<!-- in a directory at startup, without the need for additional -->
<!-- configuration files. It does not support hot deploy or -->
<!-- non standard contexts (see ContextDeployer above). -->
<!-- -->
<!-- This deployer is configured to deploy webapps from the -->
<!-- $JETTY_HOME/webapps directory -->
<!-- -->
<!-- Normally only one type of deployer need be used. -->
<!-- -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.deploy.WebAppDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
</Call>
</New>
</Arg>
</Call>

<!-- =========================================================== -->
<!-- Configure Authentication Login Service -->
<!-- Realms may be configured for the entire server here, or -->
<!-- they can be configured for a specific web app in a context -->
<!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
<!-- example). -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">Test Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
<Set name="refreshInterval">0</Set>
</New>
</Arg>
</Call>

<!-- =========================================================== -->
<!-- Configure Request Log -->
<!-- Request logs may be configured for the entire server here, -->
<!-- or they can be configured for a specific web app in a -->
<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
<!-- for an example). -->
<!-- =========================================================== -->
<Ref id="RequestLog">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
<Set name="filename"><SystemProperty name="jetty.home" default="."/>/logs/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">false</Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
</Ref>

<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>

</Configure>
@@ -0,0 +1,9 @@
<%
@path = '/etc/monit/monit.d/monit-jetty.conf'
%>
<% PIDFILE = "/var/run/jetty.pid" %>
check process jetty with pidfile <%= PIDFILE %>
group jetty-<%= RUBBER_ENV %>
start program = "<%= rubber_env.jetty_dir %>/bin/jetty.sh start"
stop program = "<%= rubber_env.jetty_dir %>/bin/jetty.sh stop"
if failed host <%= rubber_env.host %> port <%= rubber_env.jetty_port %> with timeout 10 seconds for 10 cycles then restart
@@ -0,0 +1,8 @@
jetty_version: 7.0.0.v20091005
jetty_prefix: /opt
jetty_dir: "#{jetty_prefix}/jetty"
jetty_port: 8080

roles:
jetty:
packages: [openjdk-6-jdk]
1 change: 1 addition & 0 deletions generators/vulcanize/templates/jetty/templates.yml
@@ -0,0 +1 @@
description: Jetty HTTP server and servlet container module
Expand Up @@ -8,7 +8,7 @@
after "rubber:install_packages", "rubber:redis:custom_install"

task :custom_install, :roles => :redis do
custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.01-1', '! -x /usr/bin/redis-server')
custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.02-1', '! -x /usr/bin/redis-server')
end

desc "Stops the redis server"
Expand Down

0 comments on commit b902618

Please sign in to comment.