Sha256: f517d7685433cdd5735c2de190229a231f75716def728e64a6a0a04731af8137

Contents?: true

Size: 799 Bytes

Versions: 17

Compression:

Stored size: 799 Bytes

Contents

require "spring/version"

module Spring
  module Client
    class Stop < Command
      TIMEOUT = 2 # seconds

      def self.description
        "Stop all spring processes for this project."
      end

      def call
        if env.server_running?
          timeout = Time.now + TIMEOUT
          kill 'TERM'
          sleep 0.1 until !env.server_running? || Time.now >= timeout

          if env.server_running?
            $stderr.puts "Spring did not stop; killing forcibly."
            kill 'KILL'
          else
            puts "Spring stopped."
          end
        else
          puts "Spring is not running"
        end
      end

      def kill(sig)
        pid = env.pid
        Process.kill(sig, pid) if pid
      rescue Errno::ESRCH
        # already dead
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spring-1.2.0 lib/spring/client/stop.rb
spring-1.1.3 lib/spring/client/stop.rb
spring-1.1.2 lib/spring/client/stop.rb
spring-1.1.1 lib/spring/client/stop.rb
spring-1.1.0 lib/spring/client/stop.rb
spring-1.1.0.beta4 lib/spring/client/stop.rb
spring-1.1.0.beta3 lib/spring/client/stop.rb
spring-1.1.0.beta2 lib/spring/client/stop.rb
spring-1.1.0.beta1 lib/spring/client/stop.rb
spring-1.0.0 lib/spring/client/stop.rb
spring-0.9.2 lib/spring/client/stop.rb
spring-0.9.1 lib/spring/client/stop.rb
spring-0.9.0 lib/spring/client/stop.rb
spring-0.0.11 lib/spring/client/stop.rb
spring-0.0.10 lib/spring/client/stop.rb
spring-0.0.9 lib/spring/client/stop.rb
spring-0.0.8 lib/spring/client/stop.rb