Change. Use service::control event to control services (#1790)

* Change. Use `service::control` event to control services

This is more FS way. E.g. sofia sends `sofia::register` event
and add all information to headers. So now `service` script
emit `fusion::service::control` event and each service responsible
for test its own name. This also allows add in future evnets to
e.g. monitor service status like `fusion::service::satus` so it
will be possible write service which will be restart services.

* Change. rename service name from `flow` to `call_flow`
This commit is contained in:
Alexey Melnichuk
2016-08-02 14:00:49 -06:00
committed by FusionPBX
parent 865b1b5019
commit f214625ead
4 changed files with 75 additions and 10 deletions
@@ -69,12 +69,14 @@ events:bind("SHUTDOWN", function(self, name, event)
end)
-- Control commands from FusionPBX
events:bind("CUSTOM::fusion::service::" .. service_name, function(self, name, event)
events:bind("CUSTOM::fusion::service::control", function(self, name, event)
if service_name ~= event:getHeader('service-name') then return end
local command = event:getHeader('service-command')
if command == "stop" then
log.notice("get stop command")
return self:stop()
end
end
log.warningf('Unknown service command: %s', command or '<NONE>')
end)