appscrolls 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +4 -0
- data/scrolls/cf.rb +41 -16
- data/scrolls/redis.rb +17 -1
- data/scrolls/sidekiq.rb +63 -0
- data/version.rb +1 -1
- metadata +5 -5
- data/scrolls/untested/sidekiq.rb +0 -23
data/ChangeLog.md
CHANGED
data/scrolls/cf.rb
CHANGED
@@ -2,13 +2,16 @@
|
|
2
2
|
# * http://blog.cloudfoundry.com/2012/03/15/using-cloud-foundry-services-with-ruby-part-2-run-time-support-for-ruby-applications/
|
3
3
|
# * http://blog.cloudfoundry.com/2012/04/19/deploying-jruby-on-rails-applications-on-cloud-foundry/
|
4
4
|
|
5
|
-
|
5
|
+
require "yaml"
|
6
6
|
|
7
|
+
@vmc_version = '0.3.23'
|
7
8
|
@name = File.basename(File.expand_path("."))
|
9
|
+
@cf_ruby_runtime = "ruby19" # might change later in scrolls
|
8
10
|
|
9
|
-
gem 'vmc', "~> #{vmc_version}"
|
11
|
+
gem 'vmc', "~> #{@vmc_version}"
|
10
12
|
gem 'cf-runtime'
|
11
13
|
|
14
|
+
known_services = %w[postgresql mysql redis mongodb]
|
12
15
|
required_dbs = %w[mysql postgresql]
|
13
16
|
|
14
17
|
selected_db = required_dbs.find { |db| scroll? db }
|
@@ -17,7 +20,7 @@ unless selected_db
|
|
17
20
|
exit_now = true
|
18
21
|
end
|
19
22
|
|
20
|
-
|
23
|
+
$cf_manifest = {"applications"=>
|
21
24
|
{"."=>
|
22
25
|
{"name"=>@name,
|
23
26
|
"framework"=>
|
@@ -25,26 +28,24 @@ manifest = {"applications"=>
|
|
25
28
|
"info"=>
|
26
29
|
{"mem"=>"256M", "description"=>"Rails Application", "exec"=>nil}},
|
27
30
|
"url"=>"${name}.${target-base}",
|
31
|
+
"runtime"=>@cf_ruby_runtime,
|
28
32
|
"mem"=>"256M",
|
29
33
|
"instances"=>1,
|
30
34
|
"services"=>{}}}}
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
db_password = config['pg_password'] || ''
|
37
|
-
when :mysql
|
38
|
-
manifest["applications"]["."]["services"]["#{@name}-mysql"] = {"type"=>"mysql"}
|
36
|
+
known_services.each do |service|
|
37
|
+
if scroll? service
|
38
|
+
$cf_manifest["applications"]["."]["services"]["#{@name}-#{service}"] = {"type"=>service}
|
39
|
+
end
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
db_username = config['pg_username'] || 'root'
|
43
|
+
db_password = config['pg_password'] || ''
|
43
44
|
|
44
45
|
exit 1 if exit_now
|
45
46
|
|
46
47
|
after_bundler do
|
47
|
-
|
48
|
+
cf_delete_app @name
|
48
49
|
|
49
50
|
# Desirable to vendor everything
|
50
51
|
run "bundle package"
|
@@ -63,15 +64,39 @@ after_bundler do
|
|
63
64
|
end
|
64
65
|
|
65
66
|
after_everything do
|
67
|
+
create_file "manifest.yml", $cf_manifest.to_yaml
|
68
|
+
|
66
69
|
run "rake assets:precompile"
|
67
70
|
if jruby?
|
68
71
|
run "warble"
|
69
72
|
run "mkdir -p deploy"
|
70
73
|
run "cp #{project_name}.war deploy/"
|
71
74
|
end
|
72
|
-
run "vmc _#{vmc_version}_ push #{project_name} --runtime
|
73
|
-
run "vmc _#{vmc_version}_ env-add #{project_name} BUNDLE_WITHOUT=assets:test:development"
|
74
|
-
run "vmc _#{vmc_version}_ start #{project_name}"
|
75
|
+
run "vmc _#{@vmc_version}_ push #{project_name} --runtime #{@cf_ruby_runtime} --path . --no-start"
|
76
|
+
run "vmc _#{@vmc_version}_ env-add #{project_name} BUNDLE_WITHOUT=assets:test:development"
|
77
|
+
run "vmc _#{@vmc_version}_ start #{project_name}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def cf_delete_app(name)
|
81
|
+
run %Q{vmc _#{@vmc_version}_ apps | grep "\\b#{name}\\b" && vmc _#{@vmc_version}_ delete #{name}}
|
82
|
+
end
|
83
|
+
|
84
|
+
def cf_standalone_command(key, name, command, services={})
|
85
|
+
cf_manifest = {"applications"=>
|
86
|
+
{"."=>
|
87
|
+
{"name"=>name,
|
88
|
+
"framework"=>
|
89
|
+
{"name"=>"standalone",
|
90
|
+
"info"=>
|
91
|
+
{"mem"=>"64M", "description"=>"Standalone Application", "exec"=>nil}},
|
92
|
+
"url"=>nil,
|
93
|
+
"runtime"=>@cf_ruby_runtime,
|
94
|
+
"command"=>command,
|
95
|
+
"mem"=>"256M",
|
96
|
+
"instances"=>1,
|
97
|
+
"services"=>services}}}
|
98
|
+
create_file "manifest.#{key}.yml", cf_manifest.to_yaml
|
99
|
+
"manifest.#{key}.yml"
|
75
100
|
end
|
76
101
|
|
77
102
|
__END__
|
data/scrolls/redis.rb
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
gem 'redis'
|
2
2
|
|
3
3
|
initializer "redis.rb", <<-RUBY
|
4
|
-
|
4
|
+
if ENV['VCAP_SERVICES']
|
5
|
+
$vcap_services ||= JSON.parse(ENV['VCAP_SERVICES'])
|
6
|
+
redis_service_name = $vcap_services.keys.find { |svc| svc =~ /redis/i }
|
7
|
+
redis_service = $vcap_services[redis_service_name].first
|
8
|
+
$redis_config = {
|
9
|
+
host: redis_service['credentials']['host'],
|
10
|
+
port: redis_service['credentials']['port'],
|
11
|
+
password: redis_service['credentials']['password']
|
12
|
+
}
|
13
|
+
else
|
14
|
+
$redis_config = {
|
15
|
+
host: '127.0.0.1',
|
16
|
+
port: 6379
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
$redis = Redis.new($redis_config)
|
5
21
|
RUBY
|
6
22
|
|
7
23
|
if scroll? "eycloud_recipes_on_deploy"
|
data/scrolls/sidekiq.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
gem "sidekiq"
|
2
|
+
# slim/sinatra are used for the sidekiq monitoring UI at /sidekiq/SECRET
|
3
|
+
gem "slim"
|
4
|
+
gem "sinatra", ">= 1.3.0", require: false
|
5
|
+
|
6
|
+
initializer "sidekiq.rb", <<-RUBY
|
7
|
+
if $redis_config[:password]
|
8
|
+
redis_url = "redis://:\#{$redis_config[:password]}@\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
|
9
|
+
else
|
10
|
+
redis_url = "redis://\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
|
11
|
+
end
|
12
|
+
Rails.logger.info "Setting sidekiq redis: \#{{ url: redis_url, namespace: 'sidekiq' }.inspect}"
|
13
|
+
Sidekiq.redis = { url: redis_url, namespace: 'sidekiq' }
|
14
|
+
RUBY
|
15
|
+
|
16
|
+
if scroll? "eycloud_recipes_on_deploy"
|
17
|
+
gem "eycloud-recipe-sidekiq", :group => :eycloud
|
18
|
+
|
19
|
+
append_file "deploy/cookbooks/main/recipes/default.rb", <<-RUBY
|
20
|
+
|
21
|
+
require_recipe "sidekiq"
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
|
25
|
+
directory "app/workers"
|
26
|
+
create_file "app/workers/.gitkeep", ""
|
27
|
+
|
28
|
+
after_bundler do
|
29
|
+
route <<-RUBY
|
30
|
+
require "sidekiq/web"
|
31
|
+
mount Sidekiq::Web, at: "/sidekiq/#{config['sidekiq_admin_secret']}"
|
32
|
+
require "sidekiq/api"
|
33
|
+
match "queue-status" => proc { [200, {"Content-Type" => "text/plain"}, [Sidekiq::Queue.new.size < 100 ? "OK" : "UHOH" ]] }
|
34
|
+
RUBY
|
35
|
+
end
|
36
|
+
|
37
|
+
after_everything do
|
38
|
+
if scroll? "cf"
|
39
|
+
worker_name = "#{@name}-worker"
|
40
|
+
services = $cf_manifest["applications"]["."]["services"]
|
41
|
+
manifest_file = cf_standalone_command("worker", worker_name, "bundle exec sidekiq -e production", services)
|
42
|
+
cf_delete_app worker_name
|
43
|
+
run "vmc _#{@vmc_version}_ push #{worker_name} --runtime #{@cf_ruby_runtime} --path . --manifest #{manifest_file}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
__END__
|
48
|
+
|
49
|
+
name: Sidekiq
|
50
|
+
description: Simple, efficient message processing for your Rails 3 application
|
51
|
+
author: drnic
|
52
|
+
|
53
|
+
exclusive: worker
|
54
|
+
category: worker
|
55
|
+
tags: [worker,background-tasks]
|
56
|
+
|
57
|
+
requires: [redis]
|
58
|
+
run_after: [redis, eycloud_recipes_on_deploy, cf]
|
59
|
+
|
60
|
+
config:
|
61
|
+
- sidekiq_admin_secret:
|
62
|
+
type: string
|
63
|
+
prompt: "Enter a secret string for the route /sidekiq/SECRET:"
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appscrolls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- scrolls/redis.rb
|
231
231
|
- scrolls/resque.rb
|
232
232
|
- scrolls/rspec.rb
|
233
|
+
- scrolls/sidekiq.rb
|
233
234
|
- scrolls/simple_form.rb
|
234
235
|
- scrolls/split.rb
|
235
236
|
- scrolls/sqlite3.rb
|
@@ -276,7 +277,6 @@ files:
|
|
276
277
|
- scrolls/untested/sequel.rb
|
277
278
|
- scrolls/untested/settingslogic.rb
|
278
279
|
- scrolls/untested/shoulda_matchers.rb
|
279
|
-
- scrolls/untested/sidekiq.rb
|
280
280
|
- scrolls/untested/slim.rb
|
281
281
|
- scrolls/untested/spork.rb
|
282
282
|
- scrolls/untested/thinking_sphinx.rb
|
@@ -308,7 +308,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
segments:
|
310
310
|
- 0
|
311
|
-
hash:
|
311
|
+
hash: 4286488136917017513
|
312
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
313
313
|
none: false
|
314
314
|
requirements:
|
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
317
|
version: '0'
|
318
318
|
segments:
|
319
319
|
- 0
|
320
|
-
hash:
|
320
|
+
hash: 4286488136917017513
|
321
321
|
requirements: []
|
322
322
|
rubyforge_project:
|
323
323
|
rubygems_version: 1.8.25
|
data/scrolls/untested/sidekiq.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
gem "sidekiq"
|
2
|
-
|
3
|
-
if scroll? "eycloud_recipes_on_deploy"
|
4
|
-
gem "eycloud-recipe-sidekiq", :group => :eycloud
|
5
|
-
|
6
|
-
append_file "deploy/cookbooks/main/recipes/default.rb", <<-RUBY
|
7
|
-
|
8
|
-
require_recipe "sidekiq"
|
9
|
-
RUBY
|
10
|
-
end
|
11
|
-
|
12
|
-
__END__
|
13
|
-
|
14
|
-
name: Sidekiq
|
15
|
-
description: Simple, efficient message processing for your Rails 3 application
|
16
|
-
author: drnic
|
17
|
-
|
18
|
-
exclusive: worker
|
19
|
-
category: worker
|
20
|
-
tags: [worker,background-tasks]
|
21
|
-
|
22
|
-
requires: [redis]
|
23
|
-
run_after: [redis, eycloud_recipes_on_deploy]
|