Skip to content

Commit

Permalink
ZCS-16412: Added command to manage the proxy timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
swathy-shaji committed Jan 8, 2025
1 parent a4c2b15 commit 05f9a8d
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions src/bin/zmlicensectl
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ startLicenseDaemonService()
if [ "x$zimbra_license_daemon_offline_mode" = "x" ]; then
zimbra_license_daemon_offline_mode=false
fi
if [ "x$zimbra_license_proxy_timeout" = "x" ]; then
zimbra_license_proxy_timeout=60
fi
# Converting the value to milliseconds by appending 3 zeros
zimbra_license_proxy_timeout="${zimbra_license_proxy_timeout}000"
if [ -f ${LD_LIBRARY_PATH}/libShafer-prod-linux64.so ]; then
export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=prod --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 &
export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -Dlicense.proxy.api.http.timeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.socketTimeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.readTimeout=${zimbra_license_proxy_timeout} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=prod --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 &
else
export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=dev --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 &
export LD_LIBRARY_PATH; nohup ${ZMJAVA} -Dlicense-daemon.log.level=${zimbra_license_daemon_log_level} -Dlicense-daemon.offline.mode=${zimbra_license_daemon_offline_mode} -Dlicense.proxy.api.http.timeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.socketTimeout=${zimbra_license_proxy_timeout} -Dlicense.proxy.api.http.readTimeout=${zimbra_license_proxy_timeout} -jar $LICENSE_DAEMON_SERVICE --spring.profiles.active=dev --server.port=$LICENSE_DAEMON_SERVICE_PORT > /dev/null 2>&1 &
fi
sleep 5
checkLicenseDaemonServiceRunning
Expand Down Expand Up @@ -306,8 +311,10 @@ displayHelp()
echo " --service start|restart|stop|status"
echo " --service setLogLevel=INFO|DEBUG|ERROR|WARN"
echo " --service setOfflineMode=true|false"
echo " --service setProxyTimeout=70 (any numeric value greater than 60 is acceptable)"
echo " --service getLogLevel"
echo " --service getOfflineMode"
echo " --service getProxyTimeout"
echo " --nalpeiron start|restart|stop|status"
echo " --exportOfflineLicenseData | -exportOfflineLicenseData --exportStartTime YYYY/MM/DD --exportEndTime YYYY/MM/DD (offline only feature)"
echo " --clearLicenseWorkDir"
Expand Down Expand Up @@ -383,6 +390,19 @@ case "$1" in
exit 0
;;

"getProxyTimeout")
# Ensure exact match for "getOfflineMode"
if [ "$#" -ne 2 ]; then
displayHelp
exit 1
fi
# Read the current log level from CONFIG_FILE
proxyTimeout=$(grep "zimbra_license_proxy_timeout" "$CONFIG_FILE" | cut -d '=' -f 2)
# Output the current log level
echo "Current proxy timeout: $proxyTimeout seconds"
exit 0
;;

"setLogLevel=INFO"|"setLogLevel=DEBUG"|"setLogLevel=ERROR"|"setLogLevel=WARN")
loglevel=`echo $2|cut -d = -f 2`
sed -i "/zimbra_license_daemon_log_level*/c\zimbra_license_daemon_log_level="$loglevel"" $CONFIG_FILE
Expand All @@ -401,6 +421,33 @@ case "$1" in
exit 0
;;

"setProxyTimeout="*)
# Extract the timeout value from the second argument
proxyTimeout=`echo $2|cut -d = -f 2`
# Validate that the value is not empty
if [[ -z "$proxyTimeout" ]]; then
echo "Error: Proxy timeout value is missing."
exit 1
fi
# Validate if the value is numeric
if ! [[ "$proxyTimeout" =~ ^[0-9]+$ ]]; then
echo "Error: Proxy timeout must be a numeric value."
exit 1
fi
# Ensure the proxyTimeout value is greater than 60
if (( proxyTimeout <= 60 )); then
echo "Error: Proxy timeout must be greater than 60."
exit 1
fi
# Update the configuration file
sed -i "/zimbra_license_proxy_timeout*/c\zimbra_license_proxy_timeout="$proxyTimeout"" $CONFIG_FILE
# Check if the sed command succeeded
if [ $? != 0 ]; then
exit 1
fi
exit 0
;;

*)
displayHelp
exit 1
Expand Down

0 comments on commit 05f9a8d

Please sign in to comment.