It works
This commit is contained in:
commit
0e17b71ee9
|
@ -0,0 +1,14 @@
|
||||||
|
/.bundle/
|
||||||
|
/.yardoc
|
||||||
|
/Gemfile.lock
|
||||||
|
/_yardoc/
|
||||||
|
/coverage/
|
||||||
|
/doc/
|
||||||
|
/pkg/
|
||||||
|
/spec/reports/
|
||||||
|
/tmp/
|
||||||
|
*.bundle
|
||||||
|
*.so
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
mkmf.log
|
|
@ -0,0 +1,4 @@
|
||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
# Specify your gem's dependencies in mina_reboot.gemspec
|
||||||
|
gemspec
|
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright (c) 2014 Gregory Eremin
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Mina Reboot
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Add this line to your application's Gemfile:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
gem 'mina_reboot'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Add these lines to your application's deploy config:
|
||||||
|
```ruby
|
||||||
|
require 'mina/reboot'
|
||||||
|
|
||||||
|
set :on_reboot, -> {
|
||||||
|
# Tasks needed to start application
|
||||||
|
invoke 'unicorn:start'
|
||||||
|
invoke 'sidekiq:start'
|
||||||
|
}
|
||||||
|
|
||||||
|
task :deploy => :environment do
|
||||||
|
# ...
|
||||||
|
# Deploy commands
|
||||||
|
# ...
|
||||||
|
invoke 'reboot:save_startup_script'
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
1. [Fork it](https://github.com/localhots/mina_reboot/fork)
|
||||||
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||||
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||||
|
4. Push to the branch (`git push origin my-new-feature`)
|
||||||
|
5. Create a new Pull Request
|
|
@ -0,0 +1,2 @@
|
||||||
|
require "mina/reboot/version"
|
||||||
|
require "mina/reboot/save_startup_script"
|
|
@ -0,0 +1,28 @@
|
||||||
|
require 'rake'
|
||||||
|
|
||||||
|
namespace :reboot do
|
||||||
|
task :save_startup_script do
|
||||||
|
unless settings.on_reboot?
|
||||||
|
queue %| echo "-----> No reboot commands given" |
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
script_path = "#{deploy_to}/#{shared_path}/startup.sh"
|
||||||
|
log_path = "#{deploy_to}/#{shared_path}/startup.log"
|
||||||
|
|
||||||
|
script = "#!/bin/bash\n"
|
||||||
|
crontab_task = "@reboot #{script_path} > #{log_path} #minareboot"
|
||||||
|
|
||||||
|
isolate do
|
||||||
|
fetch(:on_reboot).call
|
||||||
|
script << commands.join(" && \\\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
queue %| echo "-----> Updating startup script" |
|
||||||
|
queue! %| echo '#{script}' > #{script_path} |
|
||||||
|
queue! %| chmod +x #{script_path} |
|
||||||
|
|
||||||
|
queue %| echo "-----> Updating @reboot cron task" |
|
||||||
|
queue! %| [[ $(crontab -l) != *minareboot* ]] && cat <(crontab -l) <(echo "#{crontab_task}") \| crontab - \|\| true |
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
module MinaReboot
|
||||||
|
VERSION = "0.1.0"
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
# coding: utf-8
|
||||||
|
lib = File.expand_path('../lib', __FILE__)
|
||||||
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
require 'mina/reboot/version'
|
||||||
|
|
||||||
|
Gem::Specification.new do |spec|
|
||||||
|
spec.name = "mina_reboot"
|
||||||
|
spec.version = MinaReboot::VERSION
|
||||||
|
spec.authors = ["Gregory Eremin"]
|
||||||
|
spec.email = ["g@erem.in"]
|
||||||
|
spec.summary = %q{Generates cron @reboot script from Minafile}
|
||||||
|
spec.description = %q{Generates cron @reboot script from Minafile every time you deploy, so your app will start automatically in case of server reboot}
|
||||||
|
spec.homepage = "https://github.com/localhots/mina_reboot"
|
||||||
|
spec.license = "MIT"
|
||||||
|
|
||||||
|
spec.files = `git ls-files -z`.split("\x0")
|
||||||
|
spec.executables = []
|
||||||
|
spec.test_files = []
|
||||||
|
spec.require_paths = ["lib"]
|
||||||
|
|
||||||
|
spec.add_development_dependency "bundler", "~> 1.7"
|
||||||
|
spec.add_development_dependency "rake", "~> 10.0"
|
||||||
|
end
|
Loading…
Reference in New Issue