Sha256: 85ad3c8bc3dd3fc33b88add1603409518fc2e381481a36d6224456325f2af145

Contents?: true

Size: 952 Bytes

Versions: 13

Compression:

Stored size: 952 Bytes

Contents

require 'shellwords'
require 'etc'

module Eye::Process::Validate

  class Error < Exception; 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

13 entries across 13 versions & 2 rubygems

Version Path
eye-0.8.1 lib/eye/process/validate.rb
eye-0.8.celluloid15 lib/eye/process/validate.rb
eye-0.8 lib/eye/process/validate.rb
eye-0.8.rc lib/eye/process/validate.rb
eye-0.8.pre2 lib/eye/process/validate.rb
eye-0.8.pre lib/eye/process/validate.rb
eye-0.7 lib/eye/process/validate.rb
eye-0.7.pre lib/eye/process/validate.rb
eye-0.6.4 lib/eye/process/validate.rb
eye-0.6.3 lib/eye/process/validate.rb
eye-0.6.2 lib/eye/process/validate.rb
eye-0.6.2.pre lib/eye/process/validate.rb
ace-eye-0.6.3 lib/eye/process/validate.rb