forked from luke0x/connector
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step for a Capistrano-Multistage deployment into Joyent Acceler…
…ators (work in progress) git-svn-id: http://svn.joyent.com/opensource/connector/source/trunk@536 7a7ed7af-43cf-e7d3-831c-e7cc5cc1171a
- Loading branch information
pedro@joyent.com
committed
Nov 14, 2007
1 parent
63a09a1
commit 25392f0
Showing
9 changed files
with
333 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |||
load 'config/deploy' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,96 @@ | |||
=begin #(fold) | |||
++ | |||
Copyright 2004-2007 Joyent Inc. | |||
Redistribution and/or modification of this code is | |||
governed by the GPLv2. | |||
Report issues and contribute at http://dev.joyent.com/ | |||
$Id$ | |||
-- | |||
=end #(end) | |||
|
|||
Capistrano::Configuration.instance(:must_exist).load do | |||
namespace :accelerator do | |||
|
|||
desc "Adds a SMF for the application" | |||
task :create_smf, :roles => :app do | |||
puts "set variables" | |||
service_name = application | |||
working_directory = current_path | |||
|
|||
template = File.read("config/accelerator/smf_template.erb") | |||
buffer = ERB.new(template).result(binding) | |||
|
|||
put buffer, "#{shared_path}/#{application}-smf.xml" | |||
|
|||
sudo "svccfg import #{shared_path}/#{application}-smf.xml" | |||
end | |||
|
|||
desc "Creates an Apache 2.2 compatible virtual host configuration file" | |||
task :create_vhost, :roles => :web do | |||
public_ip = "" | |||
run "#{getip}" do |ch, st, data| | |||
public_ip = data.gsub(/[\r\n]/, "") | |||
end | |||
|
|||
cluster_info = YAML.load(File.read('config/mongrel_cluster.yml')) | |||
|
|||
start_port = cluster_info['port'].to_i | |||
end_port = start_port + cluster_info['servers'].to_i - 1 | |||
public_path = "#{current_path}/public" | |||
|
|||
template = File.read("config/accelerator/apache_vhost.erb") | |||
buffer = ERB.new(template).result(binding) | |||
|
|||
put buffer, "#{shared_path}/#{application}-apache-vhost.conf" | |||
sudo "cp #{shared_path}/#{application}-apache-vhost.conf /opt/csw/apache2/etc/virtualhosts/#{application}.conf" | |||
|
|||
restart_apache | |||
end | |||
|
|||
desc "Restart apache" | |||
task :restart_apache, :roles => :web do | |||
sudo "svcadm refresh svc:/network/http:cswapache2" | |||
end | |||
|
|||
desc "Stops the application" | |||
task :smf_stop, :roles => :app do | |||
sudo "svcadm disable /network/mongrel/#{application}-production" | |||
end | |||
|
|||
desc "Starts the application" | |||
task :smf_start, :roles => :app do | |||
sudo "svcadm enable -r /network/mongrel/#{application}-production" | |||
end | |||
|
|||
desc "Restarts the application" | |||
task :smf_restart do | |||
smf_stop | |||
smf_start | |||
end | |||
|
|||
desc "Deletes the configuration" | |||
task :smf_delete, :roles => :app do | |||
sudo "svccfg delete /network/mongrel/#{application}-production" | |||
end | |||
|
|||
desc "Shows all Services" | |||
task :svcs, :roles => :app do | |||
run "svcs -a" do |ch, st, data| | |||
puts data | |||
end | |||
end | |||
|
|||
desc "After setup, creates Solaris SMF config file and adds Apache vhost" | |||
task :setup_smf_and_vhost do | |||
create_smf | |||
create_vhost | |||
end | |||
|
|||
end | |||
|
|||
after 'deploy:setup', 'accelerator:setup_smf_and_vhost' | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
<VirtualHost <%= public_ip %>:80> | |||
ServerName <%= server_name %> | |||
ServerAlias <%= server_alias %> | |||
DocumentRoot <%= public_path %> | |||
|
|||
<Directory "<%= public_path %>/"> | |||
Options FollowSymLinks | |||
AllowOverride None | |||
Order allow,deny | |||
Allow from all | |||
</Directory> | |||
|
|||
<Proxy balancer://<%= application %>-mongrels><% start_port.upto(end_port) do |port| %> | |||
BalancerMember http://127.0.0.1:<%= port %><% end %> | |||
</Proxy> | |||
|
|||
ProxyPass /images ! | |||
ProxyPass /javascripts ! | |||
ProxyPass /stylesheets ! | |||
ProxyPass / balancer://<%= application %>-mongrels/ | |||
ProxyPassReverse / balancer://<%= application %>-mongrels/ | |||
ProxyPreserveHost On | |||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
<?xml version='1.0'?> | |||
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> | |||
<service_bundle type='manifest' name='mongrel/<%= service_name %>-production'> | |||
<service name='network/mongrel/<%= service_name %>-production' type='service' version='0'> | |||
<create_default_instance enabled='true'/> | |||
<single_instance/> | |||
<dependency name='fs' grouping='require_all' restart_on='none' type='service'> | |||
<service_fmri value='svc:/system/filesystem/local'/> | |||
</dependency> | |||
<dependency name='net' grouping='require_all' restart_on='none' type='service'> | |||
<service_fmri value='svc:/network/loopback'/> | |||
<!-- uncomment the following line if you are on an L+ Accelerator since /home is mounted through nfs --> | |||
<!--<service_fmri value='svc:/network/nfs/client'/>--> | |||
</dependency> | |||
<dependent name='mongrel_multi-user' restart_on='none' grouping='optional_all'> | |||
<service_fmri value='svc:/milestone/multi-user'/> | |||
</dependent> | |||
<exec_method name='start' type='method' exec='/opt/csw/bin/mongrel_rails cluster::start' timeout_seconds='60'> | |||
<method_context working_directory='<%= working_directory %>'> | |||
<method_credential user='<%= user %>' group='<%= group %>' /> | |||
<method_environment> | |||
<envvar name='PATH' value='/usr/bin:/bin:/opt/csw/bin' /> | |||
</method_environment> | |||
</method_context> | |||
</exec_method> | |||
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'> | |||
<method_context/> | |||
</exec_method> | |||
</service> | |||
</service_bundle> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
# We have to config this properly!! | |||
|
|||
# Fill this with the real production servers. | |||
# Give a look to deploy/testing.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
# We have to config this properly!! | |||
|
|||
set :user, 'foo' | |||
|
|||
# Connector stagging servers | |||
# Give a look to deploy/testing.rb | |||
|
|||
# This is the public IP address provided with the Accelerator passwords | |||
# You may try by running this at the command line, after you checked | |||
# that have ggrep installed into the Accelerator: | |||
set :getip, "ifconfig -a | ggrep -A1 e1000g0 | grep inet | awk '{print $2}'" | |||
|
|||
set :domain, 'domain.com' | |||
|
|||
role :app, domain | |||
role :web, domain | |||
role :db, domain, :primary => true | |||
|
|||
set :server_name, "domain.com" |
Oops, something went wrong.