Sha256: accec6ff98b328f5ef0c96b074df13879b4e4f45e5dbe86945462aec31741527

Contents?: true

Size: 955 Bytes

Versions: 11

Compression:

Stored size: 955 Bytes

Contents

require 'shellwords'
require 'etc'

module Eye::Process::Validate

  class Error < RuntimeError; end

  def validate(config, localize = true)
    if (str = config[:start_command])
      # it should parse with Shellwords and not raise
      spl = Shellwords.shellwords(str) * '#'

      if config[:daemonize] && !config[:use_leaf_child]
        if spl =~ %r[sh#\-c|#&&#|;#]
          raise Error, "#{config[:name]}, daemonize does not support concats like '&&' in start_command"
        end
      end
    end

    Shellwords.shellwords(config[:stop_command]) if config[:stop_command]
    Shellwords.shellwords(config[:restart_command]) if config[:restart_command]

    if localize
      Etc.getpwnam(config[:uid]) if config[:uid]
      Etc.getgrnam(config[:gid]) if config[:gid]

      if config[:working_dir]
        raise Error, "working_dir '#{config[:working_dir]}' is invalid" unless File.directory?(config[:working_dir])
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eye-0.10.1.pre lib/eye/process/validate.rb
eye-0.10.0 lib/eye/process/validate.rb
eye-0.10.0.alpha2 lib/eye/process/validate.rb
eye-0.10.0.alpha lib/eye/process/validate.rb
eye-0.9.4.nosigar lib/eye/process/validate.rb
eye-0.9.4 lib/eye/process/validate.rb
eye-0.9.3 lib/eye/process/validate.rb
eye-0.9.2.nosigar lib/eye/process/validate.rb
eye-0.9.2 lib/eye/process/validate.rb
eye-0.9.1 lib/eye/process/validate.rb
eye-0.9.pre lib/eye/process/validate.rb