Method: PDK::CLI::Exec::Command#initialize

Defined in:
lib/pdk/cli/exec/command.rb

#initialize(*argv) ⇒ Command



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pdk/cli/exec/command.rb', line 23

def initialize(*argv)
  require 'childprocess'
  require 'tempfile'

  @argv = argv

  @process = ChildProcess.build(*@argv)
  # https://github.com/puppetlabs/pdk/issues/1083:
  # When @process.leader is set, childprocess will set the CREATE_BREAKAWAY_FROM_JOB
  # and JOB_OBJECT_LIMIT_BREAKAWAY_OK flags in the Win32 API calls. This will cause
  # issues on systems > Windows 7 / Server 2008, if the JOB_OBJECT_LIMIT_BREAKAWAY_OK
  # flag is set and the Task Scheduler is trying to kick off a job, it can sometimes
  # result in ACCESS_DENIED being returned by the Win32 API, depending on the permission
  # levels / user account this user.
  # The resolution for pdk/issues/1083 is to ensure @process.leader is not set.
  # This will potentially cause issues on older Windows systems, in which case we may
  # need to revisit and conditionally set this param depending on what OS we're on
  # @process.leader = true

  @stdout = Tempfile.new('stdout', mode: TEMPFILE_MODE).tap { |io| io.sync = true }
  @stderr = Tempfile.new('stderr', mode: TEMPFILE_MODE).tap { |io| io.sync = true }

  @process.io.stdout = @stdout
  @process.io.stderr = @stderr

  # Default to running things in the system context.
  @context = :system

  # Extra environment vars to add to base set.
  @environment = {}

  # Register the ExecGroup when running in parallel
  @exec_group = nil
end