Skip to content

Commit

Permalink
Use fork instead of spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
jrothrock committed Apr 26, 2024
1 parent 9ccf1c1 commit d3bd8fd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Ignore built gems.
*.gem
# Ignore lock file.
# Ignore lock files.
Gemfile.lock
gems/*.lock
# Ignore .idea
.idea
# Ignore log files
Expand Down
5 changes: 0 additions & 5 deletions bin/scout_apm_logging_monitor

This file was deleted.

12 changes: 6 additions & 6 deletions lib/scout_apm/logging/monitor_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ class MonitorManager
PID_FILE = '/tmp/scout_apm_log_monitor.pid'

def self.setup!
create_process
create_daemon
end

def self.create_process
def self.create_daemon
return if File.exist? PID_FILE

gem_directory = File.expand_path('../../..', __dir__)
monitor_daemon = Process.spawn("ruby #{gem_directory}/bin/scout_apm_logging_monitor &")
child_process = Process.fork do
ScoutApm::Logging::Monitor.new.run
end

# TODO: Why are we off by one?
File.write(PID_FILE, monitor_daemon + 1)
File.write(PID_FILE, child_process)

# TODO: Add exit handlers?
end
Expand Down
1 change: 1 addition & 0 deletions lib/scout_apm_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'scout_apm'

require 'scout_apm/logging/monitor_manager'
require 'scout_apm/logging/monitor/monitor'

module ScoutApm
module Logging
Expand Down

0 comments on commit d3bd8fd

Please sign in to comment.