Skip to content

Commit

Permalink
Merge pull request #67 from grip-framework/feature/versioned_interrup…
Browse files Browse the repository at this point in the history
…t_signal

feature: versioned interrupt signal
  • Loading branch information
grkek committed May 11, 2024
2 parents 305356f + 4d20600 commit 49c2a9e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/grip/application.cr
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,29 @@ module Grip
Log.info { "Listening at #{schema}://#{host}:#{port}" }

if @environment != "test"
Process.on_interrupt { exit }
{% begin %}
{% version = Crystal::VERSION.split(".").map(&.to_i) %}

{% major = version[0] %}
{% minor = version[1] %}
{% patch = version[2] %}

# 0.X.X
{% if major < 1 %}
Signal::INT.trap { exit }
{% end %}

# 1.0.0 to 1.11.X
{% if major == 1 && minor < 12 %}
Process.on_interrupt { exit }
{% end %}

# 1.12.X to 1.X.X
{% if major == 1 && minor >= 12 %}
Process.on_terminate { exit }
{% end %}
{% end %}

server.listen
end
end
Expand Down

0 comments on commit 49c2a9e

Please sign in to comment.