Class: Jackal::Utils::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/jackal/utils/process.rb

Instance Method Summary collapse

Constructor Details

#initializeself

Create new instance



14
15
16
17
18
19
20
# File 'lib/jackal/utils/process.rb', line 14

def initialize
  @storage_directory = Carnivore::Config.fetch(
    :fission, :utils, :process_manager, :storage,
    '/tmp/fission/process_manager'
  )
  FileUtils.mkdir_p(@storage_directory)
end

Instance Method Details

#create_io_tmp(*args) ⇒ IO

Temporary IO for logging

Parameters:

  • args (String)

    argument list joined for filename

Returns:

  • (IO)


42
43
44
45
46
47
48
# File 'lib/jackal/utils/process.rb', line 42

def create_io_tmp(*args)
  path = File.join(@storage_directory, args.join('-'))
  FileUtils.mkdir_p(File.dirname(path))
  t_file = File.open(path, 'w+')
  t_file.sync
  t_file
end

#process(identifier, *command) {|| ... } ⇒ TrueClass

Create new process

Parameters:

  • identifier (String)

    command identifier (compat argument)

  • command (String)

    command in single string or splatted array

Yield Parameters:

  • (ChildProcess)

Returns:

  • (TrueClass)


28
29
30
31
32
33
34
35
36
# File 'lib/jackal/utils/process.rb', line 28

def process(identifier, *command)
  if(command.size == 1)
    command = Shellwords.shellsplit(command.first)
  end
  if(block_given?)
    yield ChildProcess.build(*command)
  end
  true
end