#!/bin/bash
# supervisor - supervisor daemon support

set -e


######
# Config

sys_tool_supervisor_config_init() {
	lib_setting_vars supervisor_confdir
	supervisor_confdir="/etc/supervisor/conf.d"

	supervisor_server_packages=( supervisor )
}

sys_tool_supervisor_config_check() {
	:
}


######
# supervisor configuration

supervisor_conf() { has_args 1 "$@"; echo "$supervisor_confdir/$1"; }

supervisor_conf_exists() { has_args 1 "$@"; [ -f "$supervisor_confdir/$1" ]; }

supervisor_conf_show() {
	has_args 1 "$@"
	local name=$1
	cat "$supervisor_confdir/$1"
}

supervisor_conf_install() {
	has_args 2 "$@"
	local name=$1
	local file=$2
	local path="$supervisor_confdir/$name"
	run mv "$file" "$path"
}

supervisor_conf_remove() {
	has_args 1 "$@"
	local name=$1
	local path="$supervisor_confdir/$name"
	supervisor_conf_exists "$name" || error "$path: configuration not found"
	run rm -f "$path"
}


######
# supervisor configuration generation

supervisor_conf_gen() {
	has_args 2 "$@"
	local tag=$1
	local value=$2

	case "$tag" in
	(program|group)
		echo "[$tag:$value]"
		;;
	(command|user|directory|stopwaitseconds|programs|priority)
		echo -e "$tag=$value"
		;;
	(*)
		error "$tag: unknown supervisor configuration variable"
		;;
	esac
}


######
# supervisor control

run_supervisorctl() { run supervisorctl "$@"; }

supervisor_reload() { run_supervisorctl reload "$@"; }
supervisor_start() { run_supervisorctl start "$@"; }
supervisor_stop() { run_supervisorctl stop "$@"; }
supervisor_restart() { run_supervisorctl restart "$@"; }
supervisor_restart_all() { supervisor_restart all; }

View the Developer Guide Index

View the Reference Manual Index


Generated on Thu May 4 19:00:33 PDT 2017 by mcsh i7 v0.19.0.