├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── capistrano-eye.gemspec └── lib ├── capistrano-eye.rb └── capistrano ├── eye.rb ├── eye ├── no_hook.rb └── version.rb └── tasks ├── deploy_eye.cap └── eye.cap /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | *.bundle 19 | *.so 20 | *.o 21 | *.a 22 | mkmf.log 23 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in capistrano-eye.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Alex Sergeyev 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. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Capistrano::Eye 2 | 3 | Wrap all application processes by [eye]('https://github.com/kostya/eye') monitoring tool. 4 | 5 | ## Installation 6 | 7 | Add this line to your Gemfile: 8 | 9 | ```ruby 10 | gem 'capistrano-eye' 11 | ``` 12 | 13 | And then run: 14 | 15 | ```bash 16 | $ bundle 17 | ``` 18 | 19 | ## Usage 20 | 21 | Add this line to your `Capfile` and `deploy:restart` will be setup to automatically run after `:publishing` is complete: 22 | 23 | ```ruby 24 | require 'capistrano/eye' 25 | ``` 26 | 27 | The following tasks are available: `eye:load`, `eye:start`, `eye:stop`, `eye:quit`, `eye:restart`, `eye:info` 28 | 29 | If you want the task to run at a different point in your deployment, require `capistrano/eye/no_hook` instead of `capistrano/eye` and then add your own hook in `config/deploy.rb`. 30 | 31 | ``` ruby 32 | # Capfile 33 | require 'capistrano/eye/no_hook' 34 | 35 | # config/deploy.rb 36 | after :some_other_task, :'eye:restart' 37 | ``` 38 | 39 | ## Configuration 40 | ```ruby 41 | set :eye_roles, :app # the role of the server where the eye should be started 42 | set :eye_env, -> { { rails_env: fetch(:stage) } } # capistrano environment 43 | set :eye_application, -> { fetch(:application) } # capistrano application name by default 44 | set :eye_config, -> { "./config/#{fetch(:application)}.eye" } # ./config/eye_application.eye 45 | set :eye_work_dir, -> { release_path } # working directory path for eye 46 | ``` 47 | 48 | ## Contributing 49 | 50 | 1. Fork it ( https://github.com/[my-github-username]/capistrano-eye/fork ) 51 | 2. Create your feature branch (`git checkout -b my-new-feature`) 52 | 3. Commit your changes (`git commit -am 'Add some feature'`) 53 | 4. Push to the branch (`git push origin my-new-feature`) 54 | 5. Create a new Pull Request 55 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | -------------------------------------------------------------------------------- /capistrano-eye.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'capistrano/eye/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = 'capistrano-eye' 8 | gem.version = Capistrano::Eye::VERSION 9 | gem.authors = ['Alex Sergeyev'] 10 | gem.email = ['alex.sergeyev@gmail.com'] 11 | gem.summary = %q(Capistrano eye tasks) 12 | gem.description = %q(Capistrano tasks to manage and monitor processes by eye) 13 | gem.homepage = 'http://github.com/alexsergeyev/capistrano-eye' 14 | gem.license = 'MIT' 15 | 16 | gem.files = `git ls-files -z`.split("\x0") 17 | gem.require_paths = ['lib'] 18 | 19 | gem.add_dependency 'capistrano', '~> 3.1' 20 | gem.add_dependency 'sshkit', '~> 1.2' 21 | end 22 | -------------------------------------------------------------------------------- /lib/capistrano-eye.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexsergeyev/capistrano-eye/36600b8c9cfcabc5a74795dec2f1e998c3db982a/lib/capistrano-eye.rb -------------------------------------------------------------------------------- /lib/capistrano/eye.rb: -------------------------------------------------------------------------------- 1 | load File.expand_path("../tasks/deploy_eye.cap", __FILE__) 2 | -------------------------------------------------------------------------------- /lib/capistrano/eye/no_hook.rb: -------------------------------------------------------------------------------- 1 | load File.expand_path("../../tasks/eye.cap", __FILE__) 2 | -------------------------------------------------------------------------------- /lib/capistrano/eye/version.rb: -------------------------------------------------------------------------------- 1 | module Capistrano 2 | module Eye 3 | VERSION = '0.0.6' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/capistrano/tasks/deploy_eye.cap: -------------------------------------------------------------------------------- 1 | load File.expand_path('../eye.cap', __FILE__) 2 | 3 | namespace :deploy do 4 | desc 'Restart your Eye application' 5 | task :restart do 6 | invoke 'eye:restart' 7 | end 8 | after :publishing, :restart 9 | end 10 | 11 | -------------------------------------------------------------------------------- /lib/capistrano/tasks/eye.cap: -------------------------------------------------------------------------------- 1 | namespace :eye do 2 | desc 'Load eye config' 3 | task :load do 4 | on roles(fetch(:eye_roles)) do 5 | with fetch(:eye_env) do 6 | within fetch(:eye_work_dir) do 7 | execute :eye, :load, fetch(:eye_config) 8 | end 9 | end 10 | end 11 | end 12 | 13 | [:start, :stop, :restart].each do |cmd| 14 | desc "Run 'eye #{cmd}'" 15 | task cmd do 16 | on roles(fetch(:eye_roles)) do 17 | with fetch(:eye_env) do 18 | within fetch(:eye_work_dir) do 19 | execute :eye, cmd, fetch(:eye_application) 20 | end 21 | end 22 | end 23 | end 24 | end 25 | 26 | desc 'Show application status' 27 | task :info do 28 | on roles(fetch(:eye_roles)) do |server| 29 | puts server.hostname 30 | with fetch(:eye_env) do 31 | within fetch(:eye_work_dir) do 32 | puts capture(:eye, :info, fetch(:eye_application)) 33 | end 34 | end 35 | end 36 | end 37 | 38 | desc 'Quit eye' 39 | task :quit do 40 | on roles(fetch(:eye_roles)) do |server| 41 | with fetch(:eye_env) do 42 | within(release_path) do 43 | execute :eye, :quit 44 | end 45 | end 46 | end 47 | end 48 | 49 | before :start, :load 50 | before :restart, :load 51 | end 52 | 53 | namespace :load do 54 | task :defaults do 55 | set :eye_roles, :app 56 | set :eye_env, -> { { rails_env: fetch(:rails_env) || fetch(:stage) } } 57 | set :eye_application, -> { fetch(:application) } 58 | set :eye_config, -> { "./config/#{fetch(:application)}.eye" } 59 | set :eye_work_dir, -> { release_path } 60 | 61 | # Rbenv, Chruby, and RVM integration 62 | set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a << 'eye' 63 | set :rvm_map_bins, fetch(:rvm_map_bins).to_a << 'eye' 64 | set :chruby_map_bins, fetch(:chruby_map_bins).to_a << 'eye' 65 | # Bundler integration 66 | set :bundle_bins, fetch(:bundle_bins).to_a << 'eye' if defined?(Eye) 67 | end 68 | end 69 | --------------------------------------------------------------------------------