Skip to content

Instantly share code, notes, and snippets.

@shairyar
Created March 17, 2025 12:31
Show Gist options
  • Save shairyar/a588c6600795b85bcb7da342d5545a6c to your computer and use it in GitHub Desktop.
Save shairyar/a588c6600795b85bcb7da342d5545a6c to your computer and use it in GitHub Desktop.
Using Ruby script to start AppSignal
# Requirements:
# bundle install
# bundle exec ruby app.rb
# app.rb
require "appsignal"
# Configure appsignal if needed
Appsignal.configure do |config|
# config.<option> = value
end
Appsignal.start
at_exit { Appsignal.stop }
loop do
print "."
sleep 1
end
@jjb
Copy link

jjb commented Mar 17, 2025

I also have

raise "Appsignal did not start" unless Appsignal.started?

@jjb
Copy link

jjb commented Mar 17, 2025

%w[INT TERM].each do |signal|
  old_handler = Signal.trap(signal) do
    Appsignal.stop

    if old_handler.respond_to?(:call)
      old_handler.call
    else
      exit
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment