diff --git a/.gitignore b/.gitignore index 6e44035..0d9efbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ # Ignore built gems. *.gem -# Ignore lock file. +# Ignore lock files. Gemfile.lock +gems/*.lock # Ignore .idea .idea # Ignore log files diff --git a/bin/scout_apm_logging_monitor b/bin/scout_apm_logging_monitor deleted file mode 100644 index e156f65..0000000 --- a/bin/scout_apm_logging_monitor +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../lib/scout_apm/logging/monitor/monitor.rb" - -ScoutApm::Logging::Monitor.new.run diff --git a/lib/scout_apm/logging/monitor_manager.rb b/lib/scout_apm/logging/monitor_manager.rb index f7245b1..57490a5 100644 --- a/lib/scout_apm/logging/monitor_manager.rb +++ b/lib/scout_apm/logging/monitor_manager.rb @@ -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 diff --git a/lib/scout_apm_logging.rb b/lib/scout_apm_logging.rb index 6d7323f..67f7e97 100644 --- a/lib/scout_apm_logging.rb +++ b/lib/scout_apm_logging.rb @@ -3,6 +3,7 @@ require 'scout_apm' require 'scout_apm/logging/monitor_manager' +require 'scout_apm/logging/monitor/monitor' module ScoutApm module Logging