capistrano-mono-deploy 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -25,25 +25,39 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
- xsp4 Capfile Example
28
+ xsp4 capfile example
29
29
  --------------------
30
30
  You probably shouldn't use xsp as a production server, consider using nginx with fastcgi
31
31
 
32
32
  ```ruby
33
33
  require "capistrano/mono-deploy"
34
34
 
35
- set :app, "your.server.fqdn"
35
+ role :app, "your.server.fqdn"
36
36
  set :user, "deploy"
37
37
  set :deploy_to, "/var/apps/my-app-folder"
38
38
 
39
39
  ```
40
40
 
41
- Custom command Capfile Example
41
+ fastcgi capfile example
42
+ -----------------------
43
+ This will run fastcgi-mono-server4.exe in the background, if the process dies it will not bring it back up again
44
+
45
+ ```ruby
46
+ require "capistrano/mono-deploy"
47
+
48
+ role :app, "your.server.fqdn"
49
+ set :user, "deploy"
50
+ set :deploy_to, "/var/apps/my-app-folder"
51
+ set :mono_app, :fastcgi
52
+
53
+ ```
54
+
55
+ Custom command capfile example
42
56
  ------------------------------
43
57
  ```ruby
44
58
  require "capistrano/mono-deploy"
45
59
 
46
- set :app, "your.server.fqdn"
60
+ role :app, "your.server.fqdn"
47
61
  set :user, "deploy"
48
62
  set :deploy_to, "/var/apps/my-app-folder"
49
63
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "capistrano-mono-deploy"
7
- gem.version = "0.1.2"
7
+ gem.version = "0.1.3"
8
8
  gem.authors = ["Antony Denyer"]
9
9
  gem.email = ["antonydenyer@gmail.com"]
10
10
  gem.description = %q{some capistrano recipes for deploying mono apps on to linux servers, currently only supports xsp}
@@ -3,8 +3,8 @@ require "capistrano/mono/server"
3
3
 
4
4
  Capistrano::Configuration.instance(:must_exist).load do |configuration|
5
5
 
6
- after "deploy:update", "mono:restart"
7
- after "deploy:rollback", "mono:restart"
6
+ after "deploy:update", "deploy:restart"
7
+ after "deploy:rollback", "deploy:restart"
8
8
 
9
9
  set :application, 'Capistrano-Mono-Deploy' unless defined? application
10
10
  set :repository, File.dirname(Dir.glob("**/Web.config").first) unless defined? repository
@@ -14,7 +14,7 @@ set :copy_exclude, [".git/*","**/*.cs", "**/_*", "**/*proj", "**/obj"] unless de
14
14
 
15
15
  set :mono_app, :xsp unless defined? mono
16
16
 
17
- namespace :mono do
17
+ namespace :deploy do
18
18
  task :restart, :roles => :app do
19
19
  server = Capistrano::Deploy::MONO.new(mono_app, self)
20
20
  server.stop()
@@ -24,12 +24,12 @@ module Capistrano
24
24
  @configuration = configuration
25
25
  end
26
26
  def start()
27
- puts "starting application using custom command"
27
+ puts "> starting application using custom command"
28
28
  @configuration.run("#{start_command}")
29
29
  end
30
30
 
31
31
  def stop()
32
- puts "stopping application using custom command"
32
+ puts "> stopping application using custom command"
33
33
  @configuration.run("#{stop_command}")
34
34
  end
35
35
  end
@@ -0,0 +1,60 @@
1
+ require 'capistrano/configuration/actions/invocation'
2
+ require 'capistrano/configuration/variables'
3
+
4
+ module Capistrano
5
+ module Deploy
6
+ module MONO
7
+ class Fastcgi
8
+
9
+ def socket
10
+ socketName = @configuration.variables[:application] || "fastcgi-mono-server4"
11
+ socketName = socketName.gsub(/\s+/, "")
12
+ "/tmp/SOCK-#{socketName}"
13
+ end
14
+
15
+ def latest_release
16
+ @configuration.variables[:latest_release]
17
+ end
18
+
19
+ def initialize(configuration={})
20
+ @configuration = configuration
21
+ end
22
+ def start()
23
+ puts "starting application using fastcgi on socket #{socket}"
24
+
25
+ appDir = @configuration.capture("readlink -f #{latest_release}").strip
26
+
27
+ @configuration.run("fastcgi-mono-server4 /applications=/:#{appDir} /filename=#{socket} /socket=unix > /dev/null 2>&1 &")
28
+
29
+
30
+ attempt_number = 0
31
+ begin
32
+ attempt_number = attempt_number + 1
33
+ status = @configuration.capture("curl --write-out %{http_code} localhost --silent --location --output /dev/null ").strip.to_i
34
+ if(status >= 400)
35
+ puts "localhost responded with #{status}"
36
+ raise
37
+ end
38
+ rescue
39
+ #HACK: you should just add www-data to the user
40
+ @configuration.run("chmod 777 #{socket}")
41
+ sleep 1
42
+ retry if attempt_number < 5
43
+ puts 'You need to configure your web server for fastcgi'
44
+ puts 'For example in nginx it you need to add the following params:'
45
+ puts ''
46
+ puts 'fastcgi_pass unix:/tmp/SOCK-$http_host;'
47
+ puts ''
48
+ puts 'check out http://www.mono-project.com/FastCGI_Nginx for more details'
49
+ raise CommandError.new("Failed to bring up the site")
50
+ end
51
+ puts "The site is up"
52
+ end
53
+
54
+ def stop()
55
+ @configuration.run("pkill mono || true")
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -12,7 +12,7 @@ module Capistrano
12
12
  raise Capistrano::Error, "could not find '#{name}::#{mono_const}' in '#{mono_file}'"
13
13
  end
14
14
  rescue LoadError
15
- raise Capistrano::Error, "could not find any MONO deploy strategy named `#{mono}'"
15
+ raise Capistrano::Error, "could not find any MONO deploy strategy named '#{mono}' looking for file #{mono_file}"
16
16
  end
17
17
  end
18
18
  end
@@ -27,7 +27,11 @@ module Capistrano
27
27
  attempt_number = 0
28
28
  begin
29
29
  attempt_number = attempt_number + 1
30
- @configuration.run("curl localhost:#{port} --silent --location --output /dev/null")
30
+ status = @configuration.capture("curl --write-out %{http_code} localhost:#{port} --silent --location --output /dev/null ").strip.to_i
31
+ if(status >= 400)
32
+ puts "localhost responded with #{status}"
33
+ raise
34
+ end
31
35
  rescue
32
36
  sleep 1
33
37
  retry if attempt_number < 10
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-mono-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-13 00:00:00.000000000 Z
12
+ date: 2013-01-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: some capistrano recipes for deploying mono apps on to linux servers,
15
15
  currently only supports xsp
@@ -28,6 +28,7 @@ files:
28
28
  - lib/capistrano-mono-deploy.rb
29
29
  - lib/capistrano/mono-deploy.rb
30
30
  - lib/capistrano/mono/custom.rb
31
+ - lib/capistrano/mono/fastcgi.rb
31
32
  - lib/capistrano/mono/server.rb
32
33
  - lib/capistrano/mono/xsp.rb
33
34
  homepage: https://github.com/antonydenyer/capistrano-mono-deploy