Module: Puma::JRubyRestart

### Home Classes Methods

### In Files

- lib/puma/jruby_restart.rb

### Methods

- ::chdir_exec
- ::daemon?
- ::daemon_init
- ::daemon_start
- ::perm_daemonize

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Puma
- Puma::App
- Puma::App::Status
- Puma::Binder
- Puma::CLI
- Puma::Client
- Puma::Cluster
- Puma::Cluster::Worker
- Puma::CommonLogger
- Puma::ConfigDefault
- Puma::Configuration
- Puma::Configuration::ConfigMiddleware
- Puma::ConnectionError
- Puma::Const
- Puma::ControlCLI
- Puma::DSL
- Puma::Delegation
- Puma::Events
- Puma::Events::DefaultFormatter
- Puma::Events::PidFormatter
- Puma::IOBuffer
- Puma::JRubyRestart
- Puma::JavaIOBuffer
- Puma::MiniSSL
- Puma::MiniSSL::Context
- Puma::MiniSSL::SSLError
- Puma::MiniSSL::Server
- Puma::MiniSSL::Socket
- Puma::NullIO
- Puma::Rack
- Puma::Rack::Builder
- Puma::Rack::Options
- Puma::Rack::URLMap
- Puma::Reactor
- Puma::Runner
- Puma::Server
- Puma::Single
- Puma::TCPLogger
- Puma::ThreadPool
- Puma::ThreadPool::AutoTrim
- Puma::ThreadPool::Reaper
- Puma::UnsupportedOption
- Puma::Util
- Puma::Util::HeaderHash
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLServer
- Rack
- Rack::Handler
- Rack::Handler::Puma
- IO
- IO::WaitReadable
- Object
- Process
- String

No matching classes.

# Puma::JRubyRestart

### Constants

PermKey
RestartKey

### Public Class Methods

chdir_exec(dir, argv) click to toggle source

    # File lib/puma/jruby_restart.rb, line 14
    def self.chdir_exec(dir, argv)
      chdir(dir)
      cmd = argv.first
      argv = ([:string] * argv.size).zip(argv).flatten
      argv << :string
      argv << nil
      execlp(cmd, *argv)
      raise SystemCallError.new(FFI.errno)
    end

daemon?() click to toggle source

    # File lib/puma/jruby_restart.rb, line 34
    def self.daemon?
      ENV.key?(PermKey) || ENV.key?(RestartKey)
    end

daemon_init() click to toggle source

    # File lib/puma/jruby_restart.rb, line 38
    def self.daemon_init
      return true if ENV.key?(PermKey)

      return false unless ENV.key? RestartKey

      master = ENV[RestartKey]

      # In case the master disappears early
      begin
        Process.kill "SIGUSR2", master.to_i
      rescue SystemCallError => e
      end

      ENV[RestartKey] = ""

      setsid

      null = File.open "/dev/null", "w+"
      STDIN.reopen null
      STDOUT.reopen null
      STDERR.reopen null

      true
    end

daemon_start(dir, argv) click to toggle source

    # File lib/puma/jruby_restart.rb, line 63
    def self.daemon_start(dir, argv)
      ENV['PUMA_DAEMON_RESTART'] = Process.pid.to_s

      if k = ENV['PUMA_JRUBY_DAEMON_OPTS']
        ENV['JRUBY_OPTS'] = k
      end

      cmd = argv.first
      argv = ([:string] * argv.size).zip(argv).flatten
      argv << :string
      argv << nil

      chdir(dir)
      ret = fork
      return ret if ret != 0
      execlp(cmd, *argv)
      raise SystemCallError.new(FFI.errno)
    end

perm_daemonize() click to toggle source

Called to tell things "Your now always in daemon mode, don't try to reenter it."

    # File lib/puma/jruby_restart.rb, line 30
    def self.perm_daemonize
      ENV[PermKey] = "1"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.