We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0621783 + 12fa195 commit cf636a0Copy full SHA for cf636a0
lib/tasks/post_gc_stat_to_discord.rake
@@ -0,0 +1,25 @@
1
+desc "Post gc stats to discord channel"
2
+
3
+task post_gc_stat_to_discord: :environment do
4
+ stats = GC.stat
5
6
+ unless ENV["DISCORD_WEBHOOK_URL"].nil?
7
+ formatted_stats = JSON.pretty_generate(stats)
8
+ discord_message = <<~MULTILINE
9
+ ```json
10
+ #{formatted_stats}
11
+ ```
12
+ MULTILINE
13
14
+ payload = {content: discord_message}.to_json
15
16
+ uri = URI.parse(ENV["DISCORD_WEBHOOK_URL"])
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = (uri.scheme == "https") # Use SSL for HTTPS
19
20
+ request = Net::HTTP::Post.new(uri.path, {"Content-Type" => "application/json"})
21
+ request.body = payload
22
23
+ http.request(request)
24
+ end
25
+end
0 commit comments