capistrano-webserver 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +5 -0
- data/README.rdoc +63 -0
- data/Rakefile +14 -0
- data/capistrano-webserver.gemspec +32 -0
- data/lib/webserver/apache.rb +71 -0
- metadata +91 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= Capistrano WebServer
|
2
|
+
|
3
|
+
The purpose of this gem is to provide a common interface to handling webserver related functions within capistrano deploy scripts.
|
4
|
+
The contents of this file are still a bit of a work in progress.
|
5
|
+
|
6
|
+
= Server Support
|
7
|
+
|
8
|
+
Currently, only apache is supported.
|
9
|
+
|
10
|
+
= Configuration
|
11
|
+
|
12
|
+
== Common variables
|
13
|
+
|
14
|
+
[webserver_config] <b>default: config/webserver/webserver.conf</b>
|
15
|
+
the file to use for webserver configuration. For apache, this might be the file
|
16
|
+
containing the VirtualHost block of the site in which the project
|
17
|
+
will be running.
|
18
|
+
[webserver_link] <b>default: true</b>
|
19
|
+
Use a symlink from the webserver configuration directory to the project configuration file.
|
20
|
+
If this is set to false, the file will be copied to the webserver configuration directory.
|
21
|
+
[webserver_restart] <b>default: true</b>
|
22
|
+
Should the webserver be restarted after configuration is updated.
|
23
|
+
|
24
|
+
== Module variables
|
25
|
+
|
26
|
+
[webserver_dir] This is defined by the capistrano_webserver modules. For apache, this would generally point to
|
27
|
+
sites-enabled directory under the ServerRoot. (eg: /etc/apache2/sites-enabled)
|
28
|
+
|
29
|
+
= Tasks
|
30
|
+
|
31
|
+
Each webserver library will implement the following capistrano tasks. These tasks will only run on servers with the :web role.
|
32
|
+
|
33
|
+
== webserver:configuration
|
34
|
+
|
35
|
+
This task will handle linking or copying the configuration file from the project directory to the webserver directory.
|
36
|
+
|
37
|
+
== webserver:restart
|
38
|
+
|
39
|
+
This task will restart the webserver.
|
40
|
+
|
41
|
+
== webserver:stop
|
42
|
+
|
43
|
+
This task will stop the webserver.
|
44
|
+
|
45
|
+
== webserver:start
|
46
|
+
|
47
|
+
This task will start the webserver.
|
48
|
+
|
49
|
+
= Usage
|
50
|
+
|
51
|
+
Install the gem:
|
52
|
+
|
53
|
+
gem install capistrano-webserver
|
54
|
+
|
55
|
+
Put the following code into your capistrano deploy.rb (or other) file. For now, only apache is supported. Later, support for other webservers will be added.
|
56
|
+
|
57
|
+
require 'webserver/apache'
|
58
|
+
|
59
|
+
If your configuration or webserver requires a restart after code deploy, simply add the following hook. This will work by default, careful of overriding the variable 'webserver_restart'.
|
60
|
+
|
61
|
+
after 'deploy:update_code', 'webserver:configuration'
|
62
|
+
|
63
|
+
In the case of Apache, you do not need this. You should not need to restart the Apache server after every deploy.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('capistrano-webserver', '0.1.1') do |p|
|
6
|
+
p.description = "Common way to manage webserver configuration using capistrano"
|
7
|
+
p.url = "http://github.com/dashonet/capistrano-webserver"
|
8
|
+
p.author = "Shawn Catanzarite"
|
9
|
+
p.email = "shawn@dasho.net"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*","nbproject/**","nbproject/private/*"]
|
11
|
+
p.development_dependencies = ["capistrano"]
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{capistrano-webserver}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Shawn Catanzarite"]
|
9
|
+
s.date = %q{2011-05-02}
|
10
|
+
s.description = %q{Common way to manage webserver configuration using capistrano}
|
11
|
+
s.email = %q{shawn@dasho.net}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/webserver/apache.rb"]
|
13
|
+
s.files = ["README.rdoc", "Rakefile", "capistrano-webserver.gemspec", "lib/webserver/apache.rb", "Manifest"]
|
14
|
+
s.homepage = %q{http://github.com/dashonet/capistrano-webserver}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano-webserver", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{capistrano-webserver}
|
18
|
+
s.rubygems_version = %q{1.6.2}
|
19
|
+
s.summary = %q{Common way to manage webserver configuration using capistrano}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
s.add_development_dependency(%q<capistrano>, [">= 0"])
|
26
|
+
else
|
27
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
28
|
+
end
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<capistrano>, [">= 0"])
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
2
|
+
|
3
|
+
## common variables
|
4
|
+
set :webserver_link, true
|
5
|
+
set :webserver_config, "config/webserver/webserver.conf"
|
6
|
+
set :webserver_restart, true
|
7
|
+
|
8
|
+
## apache specific variables
|
9
|
+
set :webserver_init, "/etc/init.d/apache2"
|
10
|
+
set :webserver_dir, "/etc/apache2/sites-enabled"
|
11
|
+
|
12
|
+
after "deploy:setup", "webserver:setup"
|
13
|
+
|
14
|
+
namespace :webserver do
|
15
|
+
desc <<-DESC
|
16
|
+
setup webserver directories.
|
17
|
+
|
18
|
+
creates a directory under the shared resources directory for webserver
|
19
|
+
related files
|
20
|
+
DESC
|
21
|
+
task :setup, :roles => :web do
|
22
|
+
run "mkdir -p #{shared_path}/webserver"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc <<-DESC
|
26
|
+
update configuration.
|
27
|
+
|
28
|
+
Upload the webserver configuration file to the shared resources directory
|
29
|
+
and create a link (or copy to) the webserver configuration directory
|
30
|
+
|
31
|
+
This task is designed to push the file directly, rather than use the deployed
|
32
|
+
application directory. This means you will not need to do a deploy just to
|
33
|
+
update configuration files for the webserver.
|
34
|
+
DESC
|
35
|
+
task :configuration, :roles => :web do
|
36
|
+
# upload the file
|
37
|
+
upload "#{webserver_config}", "#{shared_path}/webserver/#{application}"
|
38
|
+
|
39
|
+
# remove the old file / link
|
40
|
+
run "#{try_sudo} rm -f #{webserver_dir}/#{application}"
|
41
|
+
|
42
|
+
# link or copy file from shared to webserver directory
|
43
|
+
if webserver_link == true
|
44
|
+
run "#{try_sudo} ln -sf #{shared_path}/webserver/#{application} #{webserver_dir}/#{application}"
|
45
|
+
else
|
46
|
+
run "#{try_sudo} cp #{shared_path}/webserver/#{application} #{webserver_dir}/#{application}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# restart the webserver
|
50
|
+
if webserver_restart == true
|
51
|
+
webserver.restart
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "start webserver (apache)"
|
56
|
+
task :start, :roles => :web do
|
57
|
+
run "#{try_sudo} #{webserver_init} start"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "stop webserver (apache)"
|
61
|
+
task :stop, :roles => :web do
|
62
|
+
run "#{try_sudo} #{webserver_init} stop"
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "restart webserver (apache)"
|
66
|
+
task :restart, :roles => :web do
|
67
|
+
run "#{try_sudo} #{webserver_init} restart"
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-webserver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Shawn Catanzarite
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-02 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: capistrano
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Common way to manage webserver configuration using capistrano
|
36
|
+
email: shawn@dasho.net
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.rdoc
|
43
|
+
- lib/webserver/apache.rb
|
44
|
+
files:
|
45
|
+
- README.rdoc
|
46
|
+
- Rakefile
|
47
|
+
- capistrano-webserver.gemspec
|
48
|
+
- lib/webserver/apache.rb
|
49
|
+
- Manifest
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/dashonet/capistrano-webserver
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --line-numbers
|
57
|
+
- --inline-source
|
58
|
+
- --title
|
59
|
+
- Capistrano-webserver
|
60
|
+
- --main
|
61
|
+
- README.rdoc
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 11
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 2
|
82
|
+
version: "1.2"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: capistrano-webserver
|
86
|
+
rubygems_version: 1.6.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Common way to manage webserver configuration using capistrano
|
90
|
+
test_files: []
|
91
|
+
|