Sha256: 315689c7745583e036c486eadaf8b23f8b56a19fed49f3e8a071e10b5ef5d43e

Contents?: true

Size: 876 Bytes

Versions: 11

Compression:

Stored size: 876 Bytes

Contents

require 'shellwords'
require 'etc'

module Eye::Process::Validate

  class Error < Exception; end

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

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

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

    Etc.getpwnam(config[:uid]) if config[:uid]
    Etc.getpwnam(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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
reel-eye-0.5.1 lib/eye/process/validate.rb
eye-0.5.1 lib/eye/process/validate.rb
reel-eye-0.5 lib/eye/process/validate.rb
eye-0.5 lib/eye/process/validate.rb
eye-0.4.2 lib/eye/process/validate.rb
reel-eye-0.4.1 lib/eye/process/validate.rb
eye-0.4.1 lib/eye/process/validate.rb
reel-eye-0.4 lib/eye/process/validate.rb
eye-0.4 lib/eye/process/validate.rb
reel-eye-0.3.2 lib/eye/process/validate.rb
eye-0.3.2 lib/eye/process/validate.rb