#!/bin/bash
#
# @file clearwater-socket-factory-mgmt-wrapper
#
# Copyright (C) Metaswitch Networks 2016
# If license terms are provided to you in a COPYING file in the root directory
# of the source code repository by which you are accessing this code, then
# the license outlined in that COPYING file applies to your use.
# Otherwise no rights are granted except for those provided to you by
# Metaswitch Networks in a separate written agreement.

# Make sure that the socket factory itself is not already running.
# It might be, if the wrapper script was previously killed (by the OOM killer,
# say) leaving the grandchild clearwater_socket_factory process still running.
pkill -9 -f -x '/usr/share/clearwater/bin/clearwater_socket_factory.*--namespace management'

# Pull in get_daemon_args function
. /usr/share/clearwater/bin/clearwater-socket-factory-common

. /etc/clearwater/config

/usr/share/clearwater/bin/clearwater_socket_factory $(get_daemon_args "/etc/clearwater-socket-factory/management.d" "management")
