changeset 72:f85a4096574d

FIX: Figure out the type of configuration file and provide the correct option flag for it: --ini, --xml, --json, --yaml
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 17 Nov 2019 09:55:23 +0100
parents 87c0189b3437
children 20902803d406
files uwsginl/files/uwsginl.in
diffstat 1 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/uwsginl/files/uwsginl.in	Sun Nov 17 09:54:40 2019 +0100
+++ b/uwsginl/files/uwsginl.in	Sun Nov 17 09:55:23 2019 +0100
@@ -67,12 +67,37 @@
 	return 1
 }
 
+# Echo name of uWSGI option for handling of configuration file with given
+# extension.
+get_config_filetype()
+{
+	case "$1" in
+	*.ini)
+		echo ini
+		;;
+	*.json|*.js)
+		echo json
+		;;
+	*.xml)
+		echo xml
+		;;
+	*.yaml|*.yml)
+		echo yaml
+		;;
+	*)
+		warn "Unknown configuration file type for \`$1'"
+		echo ini
+		return 1
+		;;
+	esac
+}
+
 if [ -n "${uwsginl_profiles}" ]; then
 	if [ -n "$2" ]; then
 		profile="$2"
 		if ! is_uwsginl_profile $profile; then
 			echo "$0: no such profile defined in uwsginl_profiles."
-		        exit 1
+			exit 1
 		fi
 		eval uwsginl_configfile=\${uwsginl_${profile}_configfile:-"%%PREFIX%%/etc/uwsginl/uwsginl-${profile}.ini"}
 		eval uwsginl_logfile=\${uwsginl_${profile}_logfile:-"/var/log/${name}-${profile}.log"}
@@ -102,22 +127,20 @@
 
 start_precmd()
 {
-	rc_flags=""
-
 	if checkyesno uwsginl_emperor; then
 		echo "Running uWSGI as Emperor. Vassals loaded from "$uwsginl_vassals_dir
 		required_dirs=${uwsginl_vassals_dir}
-		rc_flags=${rc_flags}"--emperor-pidfile ${uwsginl_pidfile} -d ${uwsginl_logfile} --emperor ${uwsginl_vassals_dir}"
+		rc_flags="--emperor-pidfile ${uwsginl_pidfile} --daemonize ${uwsginl_logfile} --emperor ${uwsginl_vassals_dir}"
 		rc_flags=${rc_flags}" --vassals-set uid=${uwsginl_uid} --vassals-set gid=${uwsginl_gid}"
 	else
-		rc_flags=${rc_flags}"--master --uid ${uwsginl_uid} --gid ${uwsginl_gid} --pidfile ${uwsginl_pidfile} -d ${uwsginl_logfile}"
+		rc_flags="--master --uid ${uwsginl_uid} --gid ${uwsginl_gid} --pidfile ${uwsginl_pidfile} --daemonize ${uwsginl_logfile}"
 	fi
 
 	rc_flags=${rc_flags}" ${uwsginl_flags}"
 
 	# put the configfile last so that all given options can be overwritten
 	if [ -e ${uwsginl_configfile} ]; then
-		rc_flags=${rc_flags}" --ini ${uwsginl_configfile} "
+		rc_flags=${rc_flags}" --$(get_config_filetype "${uwsginl_configfile}") ${uwsginl_configfile}"
 	fi
 }