mina-push-core 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06271749ea80314bc53e4de8e3f6c6138f561a33
4
+ data.tar.gz: 071f6df69d1019d7e2129a4d2fd3f5db774f9afd
5
+ SHA512:
6
+ metadata.gz: 2f02b9956307bd858d5a33234d3f79f07fd7a0bfd5d096e6e8a3a1e0dddab77cb58d164ee533a02aa8942771bbe3be9cdae6259a124c12317f39798661cf56a8
7
+ data.tar.gz: 7da0ccbebf65de602a571de7520de9fe25d2c2d4db1d32a716e85c7be58521b8e706c64b4038b78d292f35770ebc351b4fc68ad3497e3c1e20502d718eea91af
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ test_env/deploy/
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - "2.1.0"
6
+ services: redis
7
+ env: FORCE_ADD_SSH_KEY=1
@@ -0,0 +1,14 @@
1
+ Changelog
2
+ =========
3
+
4
+ 0.2.0 2013-08-18
5
+ ----------------
6
+
7
+ Breaking Changes:
8
+
9
+ * to load the tasks requiring 'mina_sidekiq/tasks' is needed now
10
+
11
+ Enhancements:
12
+
13
+ * add sidekiq_processes to allow launching multiple sidekiq instances
14
+ * improved checking, if old instances of sidekiq are still running
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://www.rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'push-core'
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mina-push-core (0.1.0)
5
+ mina
6
+
7
+ GEM
8
+ remote: http://www.rubygems.org/
9
+ specs:
10
+ actionmailer (4.0.5)
11
+ actionpack (= 4.0.5)
12
+ mail (~> 2.5.4)
13
+ actionpack (4.0.5)
14
+ activesupport (= 4.0.5)
15
+ builder (~> 3.1.0)
16
+ erubis (~> 2.7.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.5)
20
+ activesupport (= 4.0.5)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.5)
23
+ activemodel (= 4.0.5)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.5)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.3)
28
+ activesupport (4.0.5)
29
+ i18n (~> 0.6, >= 0.6.9)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ arel (4.0.2)
35
+ builder (3.1.4)
36
+ erubis (2.7.0)
37
+ hike (1.2.3)
38
+ i18n (0.6.9)
39
+ mail (2.5.4)
40
+ mime-types (~> 1.16)
41
+ treetop (~> 1.4.8)
42
+ mime-types (1.25.1)
43
+ mina (0.3.0)
44
+ open4
45
+ rake
46
+ minitest (4.7.5)
47
+ multi_json (1.10.1)
48
+ open4 (1.3.4)
49
+ polyglot (0.3.4)
50
+ push-core (1.0.4)
51
+ multi_json (>= 1.3.2)
52
+ rails (> 3.2)
53
+ rack (1.5.2)
54
+ rack-test (0.6.2)
55
+ rack (>= 1.0)
56
+ rails (4.0.5)
57
+ actionmailer (= 4.0.5)
58
+ actionpack (= 4.0.5)
59
+ activerecord (= 4.0.5)
60
+ activesupport (= 4.0.5)
61
+ bundler (>= 1.3.0, < 2.0)
62
+ railties (= 4.0.5)
63
+ sprockets-rails (~> 2.0.0)
64
+ railties (4.0.5)
65
+ actionpack (= 4.0.5)
66
+ activesupport (= 4.0.5)
67
+ rake (>= 0.8.7)
68
+ thor (>= 0.18.1, < 2.0)
69
+ rake (10.3.2)
70
+ sprockets (2.11.0)
71
+ hike (~> 1.2)
72
+ multi_json (~> 1.0)
73
+ rack (~> 1.0)
74
+ tilt (~> 1.1, != 1.3.0)
75
+ sprockets-rails (2.0.1)
76
+ actionpack (>= 3.0)
77
+ activesupport (>= 3.0)
78
+ sprockets (~> 2.8)
79
+ thor (0.19.1)
80
+ thread_safe (0.3.3)
81
+ tilt (1.4.1)
82
+ treetop (1.4.15)
83
+ polyglot
84
+ polyglot (>= 0.3.1)
85
+ tzinfo (0.3.39)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ mina-push-core!
92
+ push-core
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2012 Nadarei, Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
@@ -0,0 +1,82 @@
1
+ mina-sidekiq
2
+ ============
3
+
4
+ [![Build Status](https://travis-ci.org/Mic92/mina-sidekiq.png?branch=master)](https://travis-ci.org/Mic92/mina-sidekiq)
5
+
6
+ mina-sidekiq is a gem that adds tasks to aid in the deployment of [Sidekiq] (http://mperham.github.com/sidekiq/)
7
+ using [Mina] (http://nadarei.co/mina).
8
+
9
+ # Getting Start
10
+
11
+ ## Installation
12
+
13
+ gem install mina-sidekiq
14
+
15
+ ## Example
16
+
17
+ ## Usage example
18
+
19
+ require 'mina_sidekiq/tasks'
20
+ ...
21
+ # to make logs persistent between deploys
22
+ set :shared_paths, ['log']
23
+
24
+ task :setup do
25
+ # sidekiq needs a place to store its pid file and log file
26
+ queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
27
+ queue! %[mkdir -p "#{deploy_to}/shared/log/"]
28
+ end
29
+
30
+ task :deploy do
31
+ deploy do
32
+ # stop accepting new workers
33
+ invoke :'sidekiq:quiet'
34
+ invoke :'git:clone'
35
+ invoke :'deploy:link_shared_paths'
36
+ ...
37
+
38
+ to :launch do
39
+ ...
40
+ invoke :'sidekiq:restart'
41
+ end
42
+ end
43
+ end
44
+
45
+ ## Available Tasks
46
+
47
+ * sidekiq:stop
48
+ * sidekiq:start
49
+ * sidekiq:restart
50
+ * sidekiq:quiet
51
+
52
+ ## Available Options
53
+
54
+ | Option | Description |
55
+ | ------------------- | ------------------------------------------------------------------------------ |
56
+ | *sidekiq* | Sets the path to sidekiq. |
57
+ | *sidekiqctl* | Sets the path to sidekiqctl. |
58
+ | *sidekiq\_timeout* | Sets a upper limit of time a worker is allowed to finish, before it is killed. |
59
+ | *sidekiq\_log* | Sets the path to the log file of sidekiq. |
60
+ | *sidekiq\_pid* | Sets the path to the pid file of a sidekiq worker. |
61
+ | *sidekiq_processes* | Sets the number of sidekiq processes launched. |
62
+
63
+ ## Testing
64
+
65
+ The test requires a local running ssh server with the ssh keys of the current
66
+ user added to its `~/.ssh/authorized_keys`. In OS X, this is "Remote Login"
67
+ under the Sharing pref pane.
68
+
69
+ To run the full blown test suite use:
70
+
71
+ bundle exec rake test
72
+
73
+ For faster release cycle use
74
+
75
+ cd test_env
76
+ bundle exec mina deploy --verbose
77
+
78
+ ## Copyright
79
+
80
+ Copyright (c) 2013 Jörg Thalheim http://higgsboson.tk/joerg
81
+
82
+ See LICENSE for further details.
@@ -0,0 +1,52 @@
1
+ require 'rake'
2
+
3
+ desc 'Run integration tests'
4
+ task :test do
5
+ Dir.chdir("#{Rake.original_dir}/test_env") do
6
+ if ENV['FORCE_ADD_SSH_KEY']
7
+ force_add_ssh_key
8
+ end
9
+
10
+ FileUtils.rm_rf('deploy')
11
+ sh 'mina setup --verbose'
12
+ begin
13
+ # fresh deploy
14
+ sh 'mina deploy --verbose'
15
+ # second deploy
16
+ sh 'mina deploy --verbose'
17
+ rescue Exception => e
18
+ puts e.message
19
+ puts e.backtrace.inspect
20
+ log = "./deploy/shared/sidekiq.log"
21
+ if File.exists?(log)
22
+ puts "cat #{log}"
23
+ puts File.open(log).read
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def force_add_ssh_key(&block)
30
+ ssh_key = File.expand_path("~/.ssh/id_rsa.pub")
31
+ unless File.exists?(ssh_key)
32
+ sh "ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa"
33
+ end
34
+ file = File.open(ssh_key)
35
+ pub_key = file.readline
36
+ file.close
37
+
38
+ authorized_keys = File.expand_path("~/.ssh/authorized_keys")
39
+ begin
40
+ File.open(authorized_keys, 'a+') do |f|
41
+ File.chmod(0600, authorized_keys)
42
+ f.puts(pub_key)
43
+ end
44
+ rescue Exception => e
45
+ puts e.message
46
+ puts e.backtrace.inspect
47
+ ensure
48
+ File.chmod(0400, authorized_keys)
49
+ end
50
+ end
51
+
52
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ require 'mina_push_core/version'
2
+
3
+ module MinaPushCore
4
+ end
@@ -0,0 +1,96 @@
1
+ # # Modules: PushCore
2
+ # Adds settings and tasks for managing PushCore workers.
3
+ #
4
+ # ## Usage example
5
+ # require 'mina_push_core/tasks'
6
+ # ...
7
+ # task :setup do
8
+ # # push_core needs a place to store its pid file
9
+ # queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
10
+ # end
11
+ #
12
+ # task :deploy do
13
+ # deploy do
14
+ # invoke :'push_core:quiet'
15
+ # invoke :'git:clone'
16
+ # ...
17
+ #
18
+ # to :launch do
19
+ # ...
20
+ # invoke :'push_core:restart'
21
+ # end
22
+ # end
23
+ # end
24
+
25
+ require 'mina/bundler'
26
+ require 'mina/rails'
27
+
28
+ # ## Settings
29
+ # Any and all of these settings can be overriden in your `deploy.rb`.
30
+
31
+ # ### push_core
32
+ # Sets the path to push_core.
33
+ set_default :push_core, lambda { "#{bundle_bin} exec push" }
34
+
35
+ # ### push_core_log
36
+ # Sets the path to the log file of push_core
37
+ #
38
+ # To disable logging set it to "/dev/null"
39
+ set_default :push_core_log, lambda { "#{deploy_to}/#{current_path}/log/push_core.log" }
40
+
41
+ # ### sidekiq_pid
42
+ # Sets the path to the pid file of a sidekiq worker
43
+ set_default :push_core_pid, lambda { "#{deploy_to}/#{shared_path}/pids/push_core.pid" }
44
+
45
+ # ### sidekiq_processes
46
+ # Sets the number of sidekiq processes launched
47
+ set_default :push_core_processes, 1
48
+
49
+ # ## Control Tasks
50
+ namespace :push_core do
51
+ def for_each_process(&block)
52
+ sidekiq_processes.times do |idx|
53
+ pid_file = if idx == 0
54
+ push_core_pid
55
+ else
56
+ "#{push_core_pid}-#{idx}"
57
+ end
58
+ yield(pid_file, idx)
59
+ end
60
+ end
61
+
62
+ # ### push_core:stop
63
+ desc "Stop push_core"
64
+ task :stop => :environment do
65
+ queue %[echo "-----> Stop push_core"]
66
+ for_each_process do |pid_file, idx|
67
+ queue %[
68
+ if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1
69
+ then
70
+ kill -SIGINT `cat #{pid_file}`
71
+ else
72
+ echo 'push daemon is not running'
73
+ fi
74
+ ]
75
+ end
76
+ end
77
+
78
+ # ### push_core:start
79
+ desc "Start push_core"
80
+ task :start => :environment do
81
+ queue %[echo "-----> Start sidekiq"]
82
+ for_each_process do |pid_file, idx|
83
+ queue %{
84
+ cd "#{deploy_to}/#{current_path}"
85
+ nohup bundle exec push #{rails_env} -p #{pid_file} >> #{push_core_log} 2>&1 &
86
+ }
87
+ end
88
+ end
89
+
90
+ # ### push_core:restart
91
+ desc "Restart push_core"
92
+ task :restart do
93
+ invoke :'push_core:stop'
94
+ invoke :'push_core:start'
95
+ end
96
+ end
@@ -0,0 +1,5 @@
1
+ module MinaPushCore
2
+ def self.version
3
+ "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require "./lib/mina_push_core/version.rb"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "mina-push-core"
7
+ s.version = MinaPushCore.version
8
+ s.authors = ["Star Chow"]
9
+ s.email = ["puma.puma07@gmail.com"]
10
+ s.homepage = "http://github.com/starchow/mina-push-core"
11
+ s.summary = "Tasks to deploy PushCore with mina."
12
+ s.description = "Adds tasks to aid in the deployment of PushCore"
13
+ s.license = 'MIT'
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ s.post_install_message = <<-MESSAGE
20
+ Starting with 0.1.0, you have to add:
21
+
22
+ require 'mina_push_core/tasks'
23
+
24
+ in your deploy.rb to load the library
25
+ MESSAGE
26
+
27
+ s.add_runtime_dependency "mina", '~> 0'
28
+ end
@@ -0,0 +1,46 @@
1
+ require 'mina'
2
+ require 'mina/git'
3
+ require 'mina_push_core/tasks'
4
+ require 'mina/git'
5
+ require 'mina/bundler'
6
+ require 'mina/rvm'
7
+ require 'fileutils'
8
+
9
+ FileUtils.mkdir_p "#{Dir.pwd}/deploy"
10
+
11
+ set :ssh_options, '-o StrictHostKeyChecking=no'
12
+
13
+ set :domain, 'localhost'
14
+ set :deploy_to, "#{Dir.pwd}/deploy"
15
+ set :repository, 'https://github.com/starchow/mina-push-core-test-rails.git'
16
+ set :keep_releases, 2
17
+ set :push_core_processes, 2
18
+
19
+ set :shared_paths, ['log']
20
+
21
+ task :environment do
22
+ invoke :'rvm:use[ruby-2.0.0]'
23
+ end
24
+
25
+ task :setup => :environment do
26
+ queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
27
+ queue! %[mkdir -p "#{deploy_to}/shared/log/"]
28
+ end
29
+
30
+ task :deploy => :environment do
31
+ deploy do
32
+ invoke :'git:clone'
33
+ invoke :'deploy:link_shared_paths'
34
+ invoke :'bundle:install'
35
+
36
+ to :launch do
37
+ invoke :'push_core:start'
38
+ queue! %[sleep 3; kill -0 `cat #{push_core_pid}`]
39
+
40
+ invoke :'push_core:quiet'
41
+
42
+ invoke :'push_core:stop'
43
+ queue! %[(kill -0 `cat #{push_core_pid}`) 2> /dev/null && exit 1 || exit 0]
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-push-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Star Chow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mina
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Adds tasks to aid in the deployment of PushCore
28
+ email:
29
+ - puma.puma07@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".travis.yml"
36
+ - Changelog.md
37
+ - Gemfile
38
+ - Gemfile.lock
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - lib/mina_push_core.rb
43
+ - lib/mina_push_core/tasks.rb
44
+ - lib/mina_push_core/version.rb
45
+ - mina-push-core.gemspec
46
+ - test_env/config/deploy.rb
47
+ homepage: http://github.com/starchow/mina-push-core
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message: |2
52
+ Starting with 0.1.0, you have to add:
53
+
54
+ require 'mina_push_core/tasks'
55
+
56
+ in your deploy.rb to load the library
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.2.2
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Tasks to deploy PushCore with mina.
76
+ test_files: []