Skip to content

Commit

Permalink
pgrep for daemon process
Browse files Browse the repository at this point in the history
  • Loading branch information
jrothrock committed Apr 26, 2024
1 parent fd3423d commit 217e6e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 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
2 changes: 2 additions & 0 deletions lib/scout_apm/logging/monitor/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Launched as a daemon process by the monitor manager and Rails startup.
##

require_relative '../monitor_manager'

module ScoutApm
module Logging
class Monitor
Expand Down
7 changes: 4 additions & 3 deletions lib/scout_apm/logging/monitor_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ def self.create_process
return if File.exist? PID_FILE

gem_directory = File.expand_path('../../..', __dir__)
monitor_daemon = Process.spawn("ruby #{gem_directory}/bin/scout_apm_logging_monitor &")

Process.spawn("ruby #{gem_directory}/bin/scout_apm_logging_monitor &")
daemon_process = `pgrep -f scout_apm_logging_monitor`.to_i

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

# TODO: Add exit handlers?
end
Expand Down

0 comments on commit 217e6e8

Please sign in to comment.