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 23:00:49 +03:00
committed by FusionPBX
parent 865b1b5019
commit f214625ead
4 changed files with 75 additions and 10 deletions

View File

@@ -27,8 +27,8 @@ end
end
local service_name = "flow"
local pid_file = scripts_dir .. "/run/call_flow_subscribe.tmp"
local service_name = "call_flow"
local pid_file = scripts_dir .. "/run/" .. service_name .. ".tmp"
local events = EventConsumer.new(pid_file)
@@ -39,7 +39,9 @@ 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")