Loading scripts/run/gkfs +62 −36 Original line number Diff line number Diff line Loading @@ -56,13 +56,13 @@ wait_for_gkfs_daemons() { # Writes status to stdout if VERBOSE is true ####################################### create_pid_file() { local pid_file=${SRUN_DAEMON_PID_FILE} local daemon_pid_file=${SRUN_DAEMON_PID_FILE} local pid=${1} if [[ ${VERBOSE} == true ]]; then echo -e "${C_AST_GREEN}Creating pid file at ${pid_file} with pid ${pid} ..." echo -e "${C_AST_GREEN}Creating pid file at ${daemon_pid_file} with pid ${pid} ..." fi # if PID file exists another daemon could run if [[ -e ${pid_file} ]]; then if [[ -e ${daemon_pid_file} ]]; then local pid_file_tmp=${SRUN_DAEMON_PID_FILE}.swp # create empty tmp file truncate -s 0 "${pid_file_tmp}" Loading @@ -72,11 +72,11 @@ create_pid_file() { # process with pid still running echo "${line}" >> "${pid_file_tmp}" fi done < "${pid_file}" done < "${daemon_pid_file}" # create pid file with only valid pids mv "${pid_file_tmp}" "${pid_file}" mv "${pid_file_tmp}" "${daemon_pid_file}" fi echo "${pid}" >> "${pid_file}" echo "${pid}" >> "${daemon_pid_file}" } ####################################### # Starts GekkoFS daemons. Loading Loading @@ -174,35 +174,35 @@ start_daemon() { echo -e "${C_AST_GREEN}GekkoFS daemons running" echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" #if [[ ${USE_PROXY} == true ]]; then # echo -e "${C_AST_GREEN}Starting GekkoFS proxies (${NODE_NUM} nodes) ..." # start_time="$(date -u +%s.%3N)" # ${proxy_execute} & # local proxy_pid=$! # sleep 5 # TODO # stop_time="$(date -u +%s.%3N)" # elapsed="$(bc <<<"$stop_time-$start_time")" # echo -e "${C_AST_GREEN}GekkoFS daemons probably :) running" # echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" #fi if [[ ${USE_PROXY} == true ]]; then echo -e "${C_AST_GREEN}Starting GekkoFS proxies (${NODE_NUM} nodes) ..." start_time="$(date -u +%s.%3N)" ${proxy_execute} & local proxy_pid=$! sleep 5 # TODO stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}GekkoFS proxies probably :) running" echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" fi if [[ ${RUN_FOREGROUND} == true ]]; then echo "Press 'q' to exit" while : ; do read -n 1 k <&1 if [[ $k = q ]] ; then #if [[ ${USE_PROXY} == true ]]; then # start_time="$(date -u +%s.%3N)" # echo # echo -e "${C_AST_GREEN}Shutting down GekkoFS proxies ..." # if [[ -n ${proxy_pid} ]]; then # kill -s SIGINT ${proxy_pid} & # wait ${proxy_pid} # fi # stop_time="$(date -u +%s.%3N)" # elapsed="$(bc <<<"$stop_time-$start_time")" # echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" #fi if [[ ${USE_PROXY} == true ]]; then start_time="$(date -u +%s.%3N)" echo echo -e "${C_AST_GREEN}Shutting down GekkoFS proxies ..." if [[ -n ${proxy_pid} ]]; then kill -s SIGINT ${proxy_pid} & wait ${proxy_pid} fi stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" fi start_time="$(date -u +%s.%3N)" echo echo -e "${C_AST_GREEN}Shutting down GekkoFS daemons ..." Loading @@ -220,20 +220,48 @@ start_daemon() { done else create_pid_file ${daemon_pid} # create_pid_file ${proxy_pid} create_pid_file ${proxy_pid} fi } ####################################### # Stops GekkoFS daemons for the configured pid file # Globals: # SRUN_DAEMON_PID_FILE # SRUN_PROXY_PID_FILE # VERBOSE # Outputs: # Writes status to stdout ####################################### stop_daemons() { local pid_file=${SRUN_DAEMON_PID_FILE} if [[ -e ${pid_file} ]]; then local daemon_pid_file=${SRUN_DAEMON_PID_FILE} local proxy_pid_file=${SRUN_PROXY_PID_FILE} # if no daemon or proxy pid file exists, exit if [[ ! -e ${daemon_pid_file} ]] && [[ ! -e ${proxy_pid_file} ]]; then echo -e "${C_AST_RED}No pid files found -> no daemon or proxy running. Exiting ..." exit 1 fi # attempt to shutdown proxy if [[ -e ${proxy_pid_file} ]]; then while IFS= read -r line do if ps -p "${line}" > /dev/null; then echo -e "${C_AST_GREEN}Stopping proxy with pid ${line}" start_time="$(date -u +%s.%3N)" kill -s SIGINT "${line}" & # poll pid until it stopped if [[ ${VERBOSE} == true ]]; then echo -e "${C_AST_GREEN}Waiting for proxies to exit ..." fi timeout 1 tail --pid=${line} -f /dev/null fi done < "${proxy_pid_file}" rm "${proxy_pid_file}" stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" fi # attempt to shutdown daemon if [[ -e ${daemon_pid_file} ]]; then while IFS= read -r line do if ps -p "${line}" > /dev/null; then Loading @@ -246,13 +274,11 @@ stop_daemons() { fi timeout 1 tail --pid=${line} -f /dev/null fi done < "${pid_file}" rm "${pid_file}" done < "${daemon_pid_file}" rm "${daemon_pid_file}" stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" else echo -e "${C_AST_RED}No pid file found -> no daemon running. Exiting ..." fi } ####################################### Loading Loading
scripts/run/gkfs +62 −36 Original line number Diff line number Diff line Loading @@ -56,13 +56,13 @@ wait_for_gkfs_daemons() { # Writes status to stdout if VERBOSE is true ####################################### create_pid_file() { local pid_file=${SRUN_DAEMON_PID_FILE} local daemon_pid_file=${SRUN_DAEMON_PID_FILE} local pid=${1} if [[ ${VERBOSE} == true ]]; then echo -e "${C_AST_GREEN}Creating pid file at ${pid_file} with pid ${pid} ..." echo -e "${C_AST_GREEN}Creating pid file at ${daemon_pid_file} with pid ${pid} ..." fi # if PID file exists another daemon could run if [[ -e ${pid_file} ]]; then if [[ -e ${daemon_pid_file} ]]; then local pid_file_tmp=${SRUN_DAEMON_PID_FILE}.swp # create empty tmp file truncate -s 0 "${pid_file_tmp}" Loading @@ -72,11 +72,11 @@ create_pid_file() { # process with pid still running echo "${line}" >> "${pid_file_tmp}" fi done < "${pid_file}" done < "${daemon_pid_file}" # create pid file with only valid pids mv "${pid_file_tmp}" "${pid_file}" mv "${pid_file_tmp}" "${daemon_pid_file}" fi echo "${pid}" >> "${pid_file}" echo "${pid}" >> "${daemon_pid_file}" } ####################################### # Starts GekkoFS daemons. Loading Loading @@ -174,35 +174,35 @@ start_daemon() { echo -e "${C_AST_GREEN}GekkoFS daemons running" echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" #if [[ ${USE_PROXY} == true ]]; then # echo -e "${C_AST_GREEN}Starting GekkoFS proxies (${NODE_NUM} nodes) ..." # start_time="$(date -u +%s.%3N)" # ${proxy_execute} & # local proxy_pid=$! # sleep 5 # TODO # stop_time="$(date -u +%s.%3N)" # elapsed="$(bc <<<"$stop_time-$start_time")" # echo -e "${C_AST_GREEN}GekkoFS daemons probably :) running" # echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" #fi if [[ ${USE_PROXY} == true ]]; then echo -e "${C_AST_GREEN}Starting GekkoFS proxies (${NODE_NUM} nodes) ..." start_time="$(date -u +%s.%3N)" ${proxy_execute} & local proxy_pid=$! sleep 5 # TODO stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}GekkoFS proxies probably :) running" echo -e "${C_AST_GREEN}Startup time: ${elapsed} seconds" fi if [[ ${RUN_FOREGROUND} == true ]]; then echo "Press 'q' to exit" while : ; do read -n 1 k <&1 if [[ $k = q ]] ; then #if [[ ${USE_PROXY} == true ]]; then # start_time="$(date -u +%s.%3N)" # echo # echo -e "${C_AST_GREEN}Shutting down GekkoFS proxies ..." # if [[ -n ${proxy_pid} ]]; then # kill -s SIGINT ${proxy_pid} & # wait ${proxy_pid} # fi # stop_time="$(date -u +%s.%3N)" # elapsed="$(bc <<<"$stop_time-$start_time")" # echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" #fi if [[ ${USE_PROXY} == true ]]; then start_time="$(date -u +%s.%3N)" echo echo -e "${C_AST_GREEN}Shutting down GekkoFS proxies ..." if [[ -n ${proxy_pid} ]]; then kill -s SIGINT ${proxy_pid} & wait ${proxy_pid} fi stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" fi start_time="$(date -u +%s.%3N)" echo echo -e "${C_AST_GREEN}Shutting down GekkoFS daemons ..." Loading @@ -220,20 +220,48 @@ start_daemon() { done else create_pid_file ${daemon_pid} # create_pid_file ${proxy_pid} create_pid_file ${proxy_pid} fi } ####################################### # Stops GekkoFS daemons for the configured pid file # Globals: # SRUN_DAEMON_PID_FILE # SRUN_PROXY_PID_FILE # VERBOSE # Outputs: # Writes status to stdout ####################################### stop_daemons() { local pid_file=${SRUN_DAEMON_PID_FILE} if [[ -e ${pid_file} ]]; then local daemon_pid_file=${SRUN_DAEMON_PID_FILE} local proxy_pid_file=${SRUN_PROXY_PID_FILE} # if no daemon or proxy pid file exists, exit if [[ ! -e ${daemon_pid_file} ]] && [[ ! -e ${proxy_pid_file} ]]; then echo -e "${C_AST_RED}No pid files found -> no daemon or proxy running. Exiting ..." exit 1 fi # attempt to shutdown proxy if [[ -e ${proxy_pid_file} ]]; then while IFS= read -r line do if ps -p "${line}" > /dev/null; then echo -e "${C_AST_GREEN}Stopping proxy with pid ${line}" start_time="$(date -u +%s.%3N)" kill -s SIGINT "${line}" & # poll pid until it stopped if [[ ${VERBOSE} == true ]]; then echo -e "${C_AST_GREEN}Waiting for proxies to exit ..." fi timeout 1 tail --pid=${line} -f /dev/null fi done < "${proxy_pid_file}" rm "${proxy_pid_file}" stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" fi # attempt to shutdown daemon if [[ -e ${daemon_pid_file} ]]; then while IFS= read -r line do if ps -p "${line}" > /dev/null; then Loading @@ -246,13 +274,11 @@ stop_daemons() { fi timeout 1 tail --pid=${line} -f /dev/null fi done < "${pid_file}" rm "${pid_file}" done < "${daemon_pid_file}" rm "${daemon_pid_file}" stop_time="$(date -u +%s.%3N)" elapsed="$(bc <<<"$stop_time-$start_time")" echo -e "${C_AST_GREEN}Shutdown time: ${elapsed} seconds" else echo -e "${C_AST_RED}No pid file found -> no daemon running. Exiting ..." fi } ####################################### Loading