mina-reboot 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: 6a94f8f2290c899946626bb9b0f11ffbf4ab4d5d
4
+ data.tar.gz: 60e5c1db72187865b663d0fcc96d70b549ddfedc
5
+ SHA512:
6
+ metadata.gz: 15748ee4bff65420b6edc14dfbf27b9ea95045220feb2fb0e3c7eca61692f552170092e7986d9c49763ae54c2f55bb4e104a6a32506ad5f353cf4ab38052e4d1
7
+ data.tar.gz: dcca77986944a130d50fdac0b25c284845e31821b51fcd2344e3d4af13956f45ede8ca9599d6e1767cbb7619d68b33d7bee26776c74e29142982070d381d1ac3
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina_reboot.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Gregory Eremin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Mina Reboot
2
+
3
+ Generates cron `@reboot` task every time you deploy with [Mina](http://nadarei.co/mina/), so your app will start automatically in case of server reboot.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mina-reboot'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Add these lines to your application's deploy config:
16
+ ```ruby
17
+ require 'mina/reboot'
18
+
19
+ set :on_reboot, -> {
20
+ # Tasks needed to start application
21
+ invoke 'unicorn:start'
22
+ invoke 'sidekiq:start'
23
+ }
24
+
25
+ task :deploy => :environment do
26
+ # ...
27
+ # Deploy commands
28
+ # ...
29
+ invoke 'reboot:save_startup_script'
30
+ end
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ 1. [Fork it](https://github.com/localhots/mina_reboot/fork)
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,2 @@
1
+ require "mina/reboot/version"
2
+ require "mina/reboot/save_startup_script"
@@ -0,0 +1,28 @@
1
+ require 'rake'
2
+
3
+ namespace :reboot do
4
+ task :save_startup_script do
5
+ unless settings.on_reboot?
6
+ queue %| echo "-----> No reboot commands given" |
7
+ next
8
+ end
9
+
10
+ script_path = "#{deploy_to}/#{shared_path}/startup.sh"
11
+ log_path = "#{deploy_to}/#{shared_path}/startup.log"
12
+
13
+ script = "#!/bin/bash\n"
14
+ crontab_task = "@reboot #{script_path} > #{log_path} #minareboot"
15
+
16
+ isolate do
17
+ fetch(:on_reboot).call
18
+ script << commands.join(" && \\\n")
19
+ end
20
+
21
+ queue %| echo "-----> Updating startup script" |
22
+ queue! %| echo '#{script}' > #{script_path} |
23
+ queue! %| chmod +x #{script_path} |
24
+
25
+ queue %| echo "-----> Updating @reboot cron task" |
26
+ queue! %| [[ $(crontab -l) != *minareboot* ]] && cat <(crontab -l) <(echo "#{crontab_task}") \| crontab - \|\| true |
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module MinaReboot
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina/reboot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina-reboot"
8
+ spec.version = MinaReboot::VERSION
9
+ spec.authors = ["Gregory Eremin"]
10
+ spec.email = ["g@erem.in"]
11
+ spec.summary = %q{Generates cron @reboot task from Mina deploy config}
12
+ spec.description = %q{Generates cron @reboot task every time you deploy with Mina, so your app will start automatically in case of server reboot}
13
+ spec.homepage = "https://github.com/localhots/mina_reboot"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = []
18
+ spec.test_files = []
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-reboot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregory Eremin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Generates cron @reboot task every time you deploy with Mina, so your
42
+ app will start automatically in case of server reboot
43
+ email:
44
+ - g@erem.in
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/mina/reboot.rb
55
+ - lib/mina/reboot/save_startup_script.rb
56
+ - lib/mina/reboot/version.rb
57
+ - mina-reboot.gemspec
58
+ homepage: https://github.com/localhots/mina_reboot
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Generates cron @reboot task from Mina deploy config
82
+ test_files: []