This repository has been archived by the owner on Aug 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SystemCallbacks module for 3rd party modules to set custom call…
…backs when OverSIP is started, reloaded (HUP signal) or stopped.
- Loading branch information
Showing
5 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module OverSIP | ||
|
||
# This module is intended for 3rd party modules that need custom code to be | ||
# executed when OverSIP is started, reloaded or terminated. | ||
# | ||
module SystemCallbacks | ||
|
||
extend ::OverSIP::Logger | ||
|
||
class << self | ||
attr_reader :on_started_callbacks | ||
attr_reader :on_terminated_callbacks | ||
attr_reader :on_reload_callbacks | ||
end | ||
|
||
@on_started_callbacks = [] | ||
@on_terminated_callbacks = [] | ||
@on_reload_callbacks = [] | ||
|
||
def self.on_started pr=nil, &bl | ||
block = pr || bl | ||
raise ::ArgumentError, "no block given" unless block.is_a? ::Proc | ||
|
||
@on_started_callbacks << block | ||
end | ||
|
||
def self.on_terminated pr=nil, &bl | ||
block = pr || bl | ||
raise ::ArgumentError, "no block given" unless block.is_a? ::Proc | ||
|
||
@on_terminated_callbacks << block | ||
end | ||
|
||
def self.on_reload pr=nil, &bl | ||
block = pr || bl | ||
raise ::ArgumentError, "no block given" unless block.is_a? ::Proc | ||
|
||
@on_reload_callbacks << block | ||
end | ||
|
||
end | ||
|
||
end |