Module: Bridgetown::Foundation::Packages::PidTracker

Defined in:
bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb

Instance Method Summary collapse

Instance Method Details

#add_pid(pid, file:) ⇒ Object



10
11
12
# File 'bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb', line 10

def add_pid(pid, file:)
  File.write pidfile_for(file), "#{pid}\n", mode: "a+"
end

#create_pid_dirObject



6
7
8
# File 'bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb', line 6

def create_pid_dir
  FileUtils.mkdir_p pids_dir
end

#read_pidfile(file) ⇒ Object



14
15
16
17
18
# File 'bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb', line 14

def read_pidfile(file)
  File.readlines pidfile_for(file), chomp: true
rescue SystemCallError
  []
end

#remove_pidfile(file) ⇒ Object



20
21
22
23
# File 'bridgetown-foundation/lib/bridgetown/foundation/packages/pid_tracker.rb', line 20

def remove_pidfile(file)
  File.delete pidfile_for(file)
rescue SystemCallError # rubocop:disable Lint/SuppressedException
end