Sha256: b8c25f8d5ff49e114074a92d2c6a86a39edfe83b41352b1366bf9b53a5eebf8c

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

Capistrano::DSL.stages.each do |stage|
  after stage, "check:running_process"
end

set :disallowed_running_processes, []

namespace :check do
  task :running_process do
    stdout, status = Open3.capture2("ps -o command")
    unless status.success?
      warn "Command failed: ps -o command"
      exit 1
    end
    processes = stdout.strip.each_line.map(&:strip)

    fetch(:disallowed_running_processes, []).each do |pattern|
      # rubocop:disable Style/CaseEquality
      next unless processes.any? {|process| pattern === process }
      # rubocop:enable Style/CaseEquality

      warn("=" * 80)
      warn("!!! Some #{pattern.inspect} process(es) are running. Please kill them. !!!")
      warn("=" * 80)
      exit 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-running_process_check-0.2.0 lib/capistrano/tasks/running_process_check.rake