mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
Feature/cache location (#50)
This commit is contained in:
parent
8d95827cb8
commit
8e5a83eede
14
tests/all.sh
14
tests/all.sh
@ -50,6 +50,15 @@ LIST_OF_SERVICES=""
|
|||||||
# Used for section folding in Travis CI
|
# Used for section folding in Travis CI
|
||||||
SECTION_UNIQUE_ID=""
|
SECTION_UNIQUE_ID=""
|
||||||
|
|
||||||
|
#Parent directory where all cache files are located in the OS
|
||||||
|
CACHE_ROOT="/var/cache"
|
||||||
|
|
||||||
|
#Name of the private directory to store the cache files
|
||||||
|
CACHE_DIR_NAME="zabbix-php-fpm"
|
||||||
|
|
||||||
|
#Full path to directory to store cache files
|
||||||
|
CACHE_DIRECTORY="$CACHE_ROOT/$CACHE_DIR_NAME"
|
||||||
|
|
||||||
# ----------------------------------
|
# ----------------------------------
|
||||||
# Colors
|
# Colors
|
||||||
# ----------------------------------
|
# ----------------------------------
|
||||||
@ -518,8 +527,9 @@ oneTimeSetUp() {
|
|||||||
#Called before every test
|
#Called before every test
|
||||||
setUp() {
|
setUp() {
|
||||||
#Delete all cache files
|
#Delete all cache files
|
||||||
sudo rm -f "/etc/zabbix/php_fpm_results.cache"
|
if [[ -d "$CACHE_DIRECTORY" ]]; then
|
||||||
sudo rm -f "/etc/zabbix/php_fpm_pending.cache"
|
sudo find "$CACHE_DIRECTORY" -type f -exec rm '{}' \;
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#Called after every test
|
#Called after every test
|
||||||
|
@ -25,6 +25,15 @@ USE_SLEEP_TIMEOUT=""
|
|||||||
#Sleep timeout in seconds
|
#Sleep timeout in seconds
|
||||||
SLEEP_TIMEOUT="0.5"
|
SLEEP_TIMEOUT="0.5"
|
||||||
|
|
||||||
|
#Parent directory where all cache files are located in the OS
|
||||||
|
CACHE_ROOT="/var/cache"
|
||||||
|
|
||||||
|
#Name of the private directory to store the cache files
|
||||||
|
CACHE_DIR_NAME="zabbix-php-fpm"
|
||||||
|
|
||||||
|
#Full path to directory to store cache files
|
||||||
|
CACHE_DIRECTORY="$CACHE_ROOT/$CACHE_DIR_NAME"
|
||||||
|
|
||||||
#Checking all the required executables
|
#Checking all the required executables
|
||||||
S_PS=$(type -P ps)
|
S_PS=$(type -P ps)
|
||||||
S_GREP=$(type -P grep)
|
S_GREP=$(type -P grep)
|
||||||
@ -118,18 +127,42 @@ if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$CACHE_ROOT" ]]; then
|
||||||
|
${S_ECHO} "The OS cache directory '$CACHE_ROOT' not found in the system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function createCacheDirectory() {
|
||||||
|
if [[ ! -d "$CACHE_DIRECTORY" ]]; then
|
||||||
|
mkdir "$CACHE_DIRECTORY"
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$CACHE_DIRECTORY" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 700 "$CACHE_DIRECTORY"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
createCacheDirectory
|
||||||
|
EXIT_CODE=$?
|
||||||
|
if [[ ${EXIT_CODE} -ne 0 ]]; then
|
||||||
|
${S_ECHO} "Failed to create cache directory '$CACHE_DIRECTORY'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
#Local directory
|
#Local directory
|
||||||
LOCAL_DIR=$(${S_DIRNAME} "$0")
|
LOCAL_DIR=$(${S_DIRNAME} "$0")
|
||||||
|
|
||||||
#Cache file for pending pools, used to store execution state
|
#Cache file for pending pools, used to store execution state
|
||||||
#File format:
|
#File format:
|
||||||
#<pool name> <socket or TCP>
|
#<pool name> <socket or TCP>
|
||||||
PENDING_FILE="$LOCAL_DIR/php_fpm_pending.cache"
|
PENDING_FILE="$CACHE_DIRECTORY/php_fpm_pending.cache"
|
||||||
|
|
||||||
#Cache file with list of active pools, used to store execution state
|
#Cache file with list of active pools, used to store execution state
|
||||||
#File format:
|
#File format:
|
||||||
#<pool name> <socket or TCP> <pool manager type>
|
#<pool name> <socket or TCP> <pool manager type>
|
||||||
RESULTS_CACHE_FILE="$LOCAL_DIR/php_fpm_results.cache"
|
RESULTS_CACHE_FILE="$CACHE_DIRECTORY/php_fpm_results.cache"
|
||||||
|
|
||||||
#Path to status script, another script of this bundle
|
#Path to status script, another script of this bundle
|
||||||
STATUS_SCRIPT="$LOCAL_DIR/zabbix_php_fpm_status.sh"
|
STATUS_SCRIPT="$LOCAL_DIR/zabbix_php_fpm_status.sh"
|
||||||
@ -331,6 +364,9 @@ function DeletePoolFromPendingList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SavePrintResults() {
|
function SavePrintResults() {
|
||||||
|
#Checking and creating cache directory just in case:
|
||||||
|
createCacheDirectory
|
||||||
|
|
||||||
#Saving pending list:
|
#Saving pending list:
|
||||||
if [[ -f $PENDING_FILE ]] && [[ ! -w $PENDING_FILE ]]; then
|
if [[ -f $PENDING_FILE ]] && [[ ! -w $PENDING_FILE ]]; then
|
||||||
echo "Error: write permission is not granted to user $ACTIVE_USER for cache file $PENDING_FILE"
|
echo "Error: write permission is not granted to user $ACTIVE_USER for cache file $PENDING_FILE"
|
||||||
|
Loading…
Reference in New Issue
Block a user