mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Add service script and make timout optional for EventConsumer ctor (#1775)
* Change. Pass pid file first. Because there really no need pass timeout. Add. `fsc` script to be able shutdown MWI and Call Flow subscribe services. * Change. rename `fsc` to `service`. * Change. Use `stop` command instead of `shutdown`
This commit is contained in:
committed by
FusionPBX
parent
32ef5c7203
commit
d47151ba8d
@@ -7,9 +7,8 @@ local Database = require "resources.functions.database"
|
||||
local cache = require "resources.functions.cache"
|
||||
local mwi_notify = require "app.voicemail.resources.functions.mwi_notify"
|
||||
|
||||
local sleep = 60000
|
||||
local service_name = "mwi"
|
||||
local pid_file = scripts_dir .. "/run/mwi_subscribe.tmp"
|
||||
local shutdown_event = "CUSTOM::fusion::mwi::shutdown"
|
||||
|
||||
local vm_message_count do
|
||||
|
||||
@@ -85,7 +84,7 @@ end
|
||||
|
||||
end
|
||||
|
||||
local events = EventConsumer.new(sleep, pid_file)
|
||||
local events = EventConsumer.new(pid_file)
|
||||
|
||||
-- FS shutdown
|
||||
events:bind("SHUTDOWN", function(self, name, event)
|
||||
@@ -93,13 +92,16 @@ events:bind("SHUTDOWN", function(self, name, event)
|
||||
return self:stop()
|
||||
end)
|
||||
|
||||
-- shutdown command
|
||||
if shutdown_event then
|
||||
events:bind(shutdown_event, function(self, name, event)
|
||||
log.notice("shutdown")
|
||||
-- Control commands from FusionPBX
|
||||
events:bind("CUSTOM::fusion::service::" .. service_name, function(self, name, event)
|
||||
local command = event:getHeader('service-command')
|
||||
if command == "stop" then
|
||||
log.notice("get stop command")
|
||||
return self:stop()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
log.warningf('Unknown service command: %s', command or '<NONE>')
|
||||
end)
|
||||
|
||||
-- MWI SUBSCRIBE
|
||||
events:bind("MESSAGE_QUERY", function(self, name, event)
|
||||
|
||||
Reference in New Issue
Block a user