Commit 295f2a9716eb72eb8b0124cf8625c6e8afb45308

Authored by edulucio
1 parent 6e74d0cf
Exists in master

Várias melhorias e correções! By Questor

.directory
1 1 [Dolphin]
2   -Timestamp=2017,3,7,14,56,41
3   -Version=3
  2 +Timestamp=2017,6,16,15,30,52
  3 +Version=4
4 4 ViewMode=1
5   -VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails
  5 +VisibleRoles=Details_text,Details_size,Details_modificationtime,Details_type,CustomizedDetails
... ...
LBGenerator.tar.gz
No preview for this file type
ez_i.bash
... ... @@ -1257,7 +1257,7 @@ f_srv_memory() {
1257 1257 : 'Informar sobre a memória do servidor.
1258 1258  
1259 1259 Returns:
1260   - F_SRV_MEMORY_R (int): Quantidade de memória RAM do servidor em KBs.
  1260 + F_SRV_MEMORY_R (int): Quantidade de memória RAM do servidor em KB.
1261 1261 '
1262 1262  
1263 1263 f_get_stderr_stdout "cat /proc/meminfo"
... ... @@ -1268,6 +1268,148 @@ f_srv_memory() {
1268 1268 F_SRV_MEMORY_R=$F_STR_TRIM_R
1269 1269 }
1270 1270  
  1271 +F_GET_PERCENT_FROM_R=0
  1272 +f_get_percent_from() {
  1273 + : 'Obter percentagem de um valor informado.
  1274 +
  1275 + Args:
  1276 + VAL_GET_PERCENT_P (int): Valor a partir do qual será obtida a
  1277 + percentagem.
  1278 + PERCENT_VAL_P (int): Valor de percentagem a ser obtido.
  1279 + REM_FLOAT_POINT_P (Optional[int]): 0 - Não remove ponto flutuante; 1 -
  1280 + remove ponto flutuante (se o valor obtido for maior ou igual a 1).
  1281 + Padrão 1.
  1282 +
  1283 + Returns:
  1284 + F_GET_PERCENT_FROM_R (int): Porcentagem obtida.
  1285 + '
  1286 +
  1287 + VAL_GET_PERCENT_P=$1
  1288 + PERCENT_VAL_P=$2
  1289 + REM_FLOAT_POINT_P=$3
  1290 + if [ -z "$REM_FLOAT_POINT_P" ] ; then
  1291 + REM_FLOAT_POINT_P=1
  1292 + fi
  1293 +
  1294 + # NOTA: A estratégia abaixo foi utilizada pq o bash por padrão não
  1295 + # permite cálculo de ponto flutuante! By Questor
  1296 + F_GET_PERCENT_FROM_R=$(awk '{printf("%.5f\n",($1*($2/100)))}' <<<" $VAL_GET_PERCENT_P $PERCENT_VAL_P ")
  1297 +
  1298 + F_GET_PERCENT_FROM_R=${F_GET_PERCENT_FROM_R}
  1299 + if [ ${REM_FLOAT_POINT_P} -eq 1 ] ; then
  1300 +
  1301 + # NOTA: Técnica para comparar valores com ponto flutuante! By Questor
  1302 + if [ $(awk '{printf($1 >= $2) ? 1 : 0}' <<<" $VAL_GET_PERCENT_P 1 ") -eq 1 ] ; then
  1303 +
  1304 + # NOTA: A estratégia abaixo foi utilizada para arredondar o valor
  1305 + # (remover o ponto flutuante)! By Questor
  1306 + F_GET_PERCENT_FROM_R=${F_GET_PERCENT_FROM_R%\.*}
  1307 + fi
  1308 + fi
  1309 +}
  1310 +
  1311 +F_BYTES_N_UNITS_R=0
  1312 +f_bytes_n_units() {
  1313 + : 'Converter bytes entre suas diversas unidades.
  1314 +
  1315 + Args:
  1316 + F_VAL_TO_CONV (int): Valor em bytes a se convertido.
  1317 + F_FROM_UNIT (str): Unidade em que o valor está (B, KB, MB, GB, TB e PB).
  1318 + F_TO_UNIT (str): Unidade para a qual se quer converter o valor (B, KB,
  1319 + MB, GB, TB e PB).
  1320 +
  1321 + Returns:
  1322 + F_BYTES_N_UNITS_R (int/float): Valor convertido para a unidade desejada.
  1323 + '
  1324 +
  1325 + # NOTE:
  1326 + # Unit Equivalent
  1327 + # 1 kilobyte (KB) 1,024 bytes
  1328 + # 1 megabyte (MB) 1,048,576 bytes
  1329 + # 1 gigabyte (GB) 1,073,741,824 bytes
  1330 + # 1 terabyte (TB) 1,099,511,627,776 bytes
  1331 + # 1 petabyte (PB) 1,125,899,906,842,624 bytes
  1332 + # By Questor
  1333 +
  1334 + F_VAL_TO_CONV=$1
  1335 + F_FROM_UNIT=$2
  1336 + F_TO_UNIT=$3
  1337 +
  1338 + CONV_LOOPS=0
  1339 + UNIT_FACTOR_0=0
  1340 + while [ ${CONV_LOOPS} -le 1 ] ; do
  1341 + UNIT_FACTOR=0
  1342 + if [ ${CONV_LOOPS} -eq 0 ] ; then
  1343 + UNIT_NOW=$F_FROM_UNIT
  1344 + else
  1345 + UNIT_NOW=$F_TO_UNIT
  1346 + fi
  1347 + case "$UNIT_NOW" in
  1348 + B)
  1349 + UNIT_FACTOR=0
  1350 + ;;
  1351 + KB)
  1352 + UNIT_FACTOR=1
  1353 + ;;
  1354 + MB)
  1355 + UNIT_FACTOR=2
  1356 + ;;
  1357 + GB)
  1358 + UNIT_FACTOR=3
  1359 + ;;
  1360 + TB)
  1361 + UNIT_FACTOR=4
  1362 + ;;
  1363 + PB)
  1364 + UNIT_FACTOR=5
  1365 + ;;
  1366 + esac
  1367 + if [ ${CONV_LOOPS} -eq 0 ] ; then
  1368 + UNIT_FACTOR_0=$UNIT_FACTOR
  1369 + else
  1370 + UNIT_FACTOR=$(awk '{printf($1-$2)}' <<<" $UNIT_FACTOR_0 $UNIT_FACTOR ")
  1371 + F_VAL_TO_CONV=$(awk '{printf("%.5f\n",($1*(1024^$2)))}' <<<" $F_VAL_TO_CONV $UNIT_FACTOR ")
  1372 + fi
  1373 + ((CONV_LOOPS++))
  1374 + done
  1375 +
  1376 + # NOTE: Remover zeros denecessários (Ex.: 0.05000 -> 0.05)!
  1377 + F_VAL_TO_CONV=$(echo $F_VAL_TO_CONV | sed 's/0\{1,\}$//')
  1378 +
  1379 + # NOTE: Remover ponto flutuante quando não necessário (Ex.: 5.00000 -> 5)!
  1380 + if [ $(echo $F_VAL_TO_CONV | awk '$0-int($0){print 0;next}{print 1}') -eq 1 ] ; then
  1381 + F_VAL_TO_CONV=${F_VAL_TO_CONV%\.*}
  1382 + fi
  1383 +
  1384 + F_BYTES_N_UNITS_R=$F_VAL_TO_CONV
  1385 +}
  1386 +
  1387 +F_PROCS_QTT_R=0
  1388 +f_procs_qtt() {
  1389 + : 'Determine the amount of processes on a server.
  1390 +
  1391 + Args:
  1392 + F_MULT_FACTOR (Optional[int]): Multiplying factor over the number of
  1393 + processes on the server. Default 1.
  1394 +
  1395 + Returns:
  1396 + F_PROCS_QTT_R (int): Number of server processes multiplied by a factor
  1397 + if informed.
  1398 + '
  1399 +
  1400 + F_MULT_FACTOR=$1
  1401 + if [ -z "$F_MULT_FACTOR" ] ; then
  1402 + F_MULT_FACTOR=1
  1403 + fi
  1404 + f_get_stderr_stdout "nproc"
  1405 + if [[ $F_GET_STDERR_R == "" ]]; then
  1406 + F_PROCS_QTT_R=$(( F_GET_STDOUT_R * F_MULT_FACTOR ))
  1407 + else
  1408 + f_enter_to_cont "An error occurred when trying to determine an appropriate amount of processes to use on this server! ERROR: \"$F_GET_STDERR_R$F_GET_STDOUT_R\"."
  1409 + f_error_exit
  1410 + fi
  1411 +}
  1412 +
1271 1413 # < --------------------------------------------------------------------------
1272 1414  
1273 1415 # > --------------------------------------------------------------------------
... ...
install.bash
... ... @@ -25,7 +25,7 @@ LBG - LBGenerator Installer
25 25 EOF
26 26  
27 27 read -d '' VERSION_F <<"EOF"
28   -0.7.0.0
  28 +0.8.0.0
29 29 EOF
30 30  
31 31 # NOTE: Para versionamento usar "MAJOR.MINOR.REVISION.BUILDNUMBER"!
... ... @@ -1056,41 +1056,6 @@ f_create_ve32() {
1056 1056 # < -----------------------------------------
1057 1057  
1058 1058 # > -----------------------------------------
1059   -# Determine an appropriate amount of processes!
1060   -
1061   -PROCESSES_QTT=0
1062   -f_num_for_procs() {
1063   - : 'Determine an appropriate amount of processes.'
1064   -
1065   - if (( PROCESSES_QTT == 0 )) ; then
1066   - f_get_stderr_stdout "nproc"
1067   - if [[ $F_GET_STDERR_R == "" ]]; then
1068   -
1069   - # NOTE: Esse é o cálculo recomendado segundo algumas fontes. Eu
1070   - # preferi fazer pelo dobro da quantidade de "cores" obtidas!
1071   - # By Questor
1072   - # (2 Workers * CPU Cores) + 1
1073   - # ---------------------------
1074   - # Para 1 core -> (2*1)+1 = 3
1075   - # Para 2 cores -> (2*2)+1 = 5
1076   - # Para 4 cores -> (2*4)+1 = 9
1077   - PROCESSES_QTT=$(( F_GET_STDOUT_R * 2 ))
1078   - f_div_section
1079   - f_get_usr_input "The recommended amount of processes to use on this server is \"$PROCESSES_QTT\".
1080   -Use empty for \"$PROCESSES_QTT\" (recommended)!" 1
1081   - if [ -n "$GET_USR_INPUT_R" ] ; then
1082   - PROCESSES_QTT=$GET_USR_INPUT_R
1083   - fi
1084   - else
1085   - f_enter_to_cont "An error occurred when trying to determine an appropriate amount of processes to use on this server! ERROR: \"$F_GET_STDERR_R$F_GET_STDOUT_R\"."
1086   - f_error_exit
1087   - fi
1088   - fi
1089   -}
1090   -
1091   -# < -----------------------------------------
1092   -
1093   -# > -----------------------------------------
1094 1059 # Instalar o NGINX (nginx)!
1095 1060  
1096 1061 NGINX_INST=0
... ... @@ -1193,8 +1158,9 @@ f_inst_nginx() {
1193 1158 \cp "$SCRIPTDIR_V/other-srcs-n-apps/nginx.conf-dist" "/etc/nginx/nginx.conf"
1194 1159  
1195 1160 # NOTE: Determinar um número adequado de processos! By Questor
1196   - f_num_for_procs
1197   - f_ez_sed "<PROCESSES_QTT>" "$PROCESSES_QTT" "/etc/nginx/nginx.conf"
  1161 + f_procs_qtt 2
  1162 +
  1163 + f_ez_sed "<PROCESSES_QTT>" "$F_PROCS_QTT_R" "/etc/nginx/nginx.conf"
1198 1164 f_ez_sed "<NGINX_PORT>" "$NGINX_PORT" "/etc/nginx/nginx.conf"
1199 1165 if [[ "$DISTRO_TYPE" == "DEB" ]] ; then
1200 1166 f_ez_sed "<SITES_ENABLED>" "\n include /etc/nginx/sites-enabled/*;" "/etc/nginx/nginx.conf"
... ... @@ -1565,13 +1531,13 @@ f_inst_lib() {
1565 1531 f_yes_no "Install the LIB - liblightbase?"
1566 1532 if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
1567 1533 EZ_I_SKIP_ON_V=$FAST_INST
1568   - f_inst_lib_py_packs 1
1569 1534 f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32/src/liblightbase" "d" "\"liblightbase\" already installed in \"$BASE_INST_DIR_V/ve32/src\"!"
1570 1535 F_BAK_MD_R=1
1571 1536 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
1572 1537 f_ez_mv_bak "$BASE_INST_DIR_V/ve32/src/liblightbase" "Backup old version and update? (\"y\" recommended)"
1573 1538 fi
1574 1539 if [ ${F_BAK_MD_R} -eq 1 ] ; then
  1540 + f_inst_lib_py_packs 1
1575 1541 cd "$SCRIPTDIR_V"
1576 1542 tar -zxvf liblightbase.tar.gz
1577 1543 mv "$SCRIPTDIR_V/liblightbase" "$BASE_INST_DIR_V/ve32/src/"
... ... @@ -1834,10 +1800,8 @@ f_inst_supervisor(){
1834 1800 f_yes_no "Install supervisor?"
1835 1801 if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
1836 1802 EZ_I_SKIP_ON_V=$FAST_INST
1837   -
1838 1803 f_inst_ve_py2X 1
1839 1804 f_create_ve2X 1
1840   -
1841 1805 f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X/src/supervisor" "d" "\"supervisor\" already installed in \"$BASE_INST_DIR_V/$VE_2_X/src/supervisor\"!"
1842 1806 UP_SUPERVISOR=1
1843 1807 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
... ... @@ -1855,12 +1819,12 @@ f_inst_supervisor(){
1855 1819 f_ez_mv_bak "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" "" 1 0 1
1856 1820 \cp "$SCRIPTDIR_V/other-srcs-n-apps/supervisord.conf-dist" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf"
1857 1821 \cp "$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf-supervisord-dist" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf"
1858   -
1859 1822 f_ez_sed "<VE_32_PATH>" "$BASE_INST_DIR_V/ve32" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" 1
1860 1823  
1861 1824 # NOTE: Determinar um número adequado de processos! By Questor
1862   - f_num_for_procs
1863   - f_ez_sed "<NUM_OF_PROCS>" "$PROCESSES_QTT" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf"
  1825 + f_procs_qtt 2
  1826 +
  1827 + f_ez_sed "<NUM_OF_PROCS>" "$F_PROCS_QTT_R" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf"
1864 1828 QUESTION_F="Enter the port number for Supervisor service.
1865 1829 Use empty for \"$SVISOR_PORT\" (recommended)!"
1866 1830 f_div_section
... ... @@ -1893,7 +1857,7 @@ Use empty for \&quot;$SVISOR_PWD\&quot;!&quot;
1893 1857 # NOTE: Calcula o máximo de memória que o LBG - LBGenerator pode usar do
1894 1858 # servidor! By Questor
1895 1859 f_div_section
1896   - f_get_usr_input "Enter the LBG - LBGenerator MAXIMUM PERCENT server RAM memory usage (numbers only, integers only, 0~100).
  1860 + f_get_usr_input "Enter the LBG - LBGenerator MAXIMUM PERCENT server RAM memory usage (numbers only, integers only).
1897 1861 Use empty for \"$PROC_MAX_MEM_PERC\" (good for most cases)!
1898 1862 * Higher values will cause server instability, crash and other unexpected results;
1899 1863 * Lower values will cause LBG - LBGenerator service instability, crash and other unexpected results." 1
... ... @@ -1901,15 +1865,8 @@ Use empty for \&quot;$PROC_MAX_MEM_PERC\&quot; (good for most cases)!
1901 1865 PROC_MAX_MEM_PERC=$GET_USR_INPUT_R
1902 1866 fi
1903 1867 f_srv_memory
1904   -
1905   - # NOTA: A estratégia abaixo foi utilizada pq o bash por padrão não
1906   - # permite cálculo de ponto flutuante! By Questor
1907   - PROC_MAX_MEM=$(awk '{printf("%.8f\n",(($1/100)*$2))}' <<<" $F_SRV_MEMORY_R $PROC_MAX_MEM_PERC ")
1908   -
1909   - # NOTA: A estratégia abaixo foi utilizada para arredondar o valor
1910   - # (remover o ponto flutuante)! By Questor
1911   - PROC_MAX_MEM=${PROC_MAX_MEM%\.*}
1912   -
  1868 + f_get_percent_from "$F_SRV_MEMORY_R" "$PROC_MAX_MEM_PERC"
  1869 + PROC_MAX_MEM=$F_GET_PERCENT_FROM_R
1913 1870 f_ez_sed "<PROC_MAX_MEM>" "$PROC_MAX_MEM" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf"
1914 1871 rm -f "/etc/init.d/supervisord"
1915 1872 if [[ "$DISTRO_TYPE" == "RH" ]] ; then
... ... @@ -2112,90 +2069,84 @@ Use empty for \&quot;$APP_ROOT_F\&quot; (will result in http://&lt;machine_ip_or_name&gt;/$APP_R
2112 2069 if [ -n "$GET_USR_INPUT_R" ] ; then
2113 2070 APP_ROOT_F=$GET_USR_INPUT_R
2114 2071 fi
2115   -
2116 2072 SQLA_POOL_SIZE=0
2117   -
2118   - # NOTA: A estratégia abaixo foi utilizada pq o bash por padrão não
2119   - # permite cálculo de ponto flutuante! By Questor
2120   - SQLA_POOL_SIZE=$(awk '{printf("%.8f\n",($1*0.8))}' <<<" $PG_CONNECTIONS ")
2121   -
2122   - # NOTA: A estratégia abaixo foi utilizada para arredondar o valor
2123   - # (remover o ponto flutuante)! By Questor
2124   - SQLA_POOL_SIZE=${SQLA_POOL_SIZE%\.*}
  2073 + SQLA_POOL_SIZE_MAX_OVERFLOW=0
  2074 + f_get_percent_from "$PG_CONNECTIONS" "48"
  2075 + SQLA_POOL_SIZE=$F_GET_PERCENT_FROM_R
  2076 + SQLA_POOL_SIZE_MAX_OVERFLOW=$SQLA_POOL_SIZE
2125 2077  
2126 2078 # NOTE: Seta uma quantidade de threads adequada para o pool do
2127 2079 # sqlalchemy! By Questor
2128 2080 f_div_section
2129 2081 f_get_usr_input "Enter the LBG - LBGenerator SQLALCHEMY POOL SIZE (numbers only, integers only).
2130 2082 Use empty for \"$SQLA_POOL_SIZE\" (good for most cases)!
2131   -* Use at most 80% of the number of PostgreSQL connections;
  2083 +* Use at most 48% of the number of PostgreSQL connections;
2132 2084 * Decrease the value if you have other applications using PostgreSQL;
2133 2085 * Higher values will cause LBG - LBGenerator and PostgreSQL services instability, crash and other unexpected results." 1
2134 2086 if [ -n "$GET_USR_INPUT_R" ] ; then
2135 2087 SQLA_POOL_SIZE=$GET_USR_INPUT_R
  2088 + SQLA_POOL_SIZE_MAX_OVERFLOW=$SQLA_POOL_SIZE
  2089 + fi
  2090 + LBI_LBINDEX_URL="http://127.0.0.1:6543/"
  2091 + QUESTION_F="Enter the LBI - LBIndex http service URL.
  2092 +Use empty for \"$LBI_LBINDEX_URL\"!"
  2093 + f_div_section
  2094 + f_get_usr_input "$QUESTION_F" 1
  2095 + QUESTION_F=""
  2096 + if [ -n "$GET_USR_INPUT_R" ] ; then
  2097 + LBI_LBINDEX_URL=$GET_USR_INPUT_R
2136 2098 fi
2137   -
2138 2099 if [[ "$HTTP_SRV_WSGI" == "u" ]] ; then
2139 2100 eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini.uwsgi-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\""
2140 2101 f_ez_sed "<SQLA_POOL_SIZE>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2141   - f_ez_sed "<SQLALCHEMY_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2102 + f_ez_sed "<SQLA_POOL_SIZE_MAX_OVERFLOW>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2103 + f_ez_sed "<LBI_LBINDEX_URL>" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2104 + f_ez_sed "<SQLA_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2142 2105 f_ez_sed "<VE32_PATH>" "$BASE_INST_DIR_V/ve32" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2143 2106 f_ez_sed "<APP_ROOT_F>" "$APP_ROOT_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
2144   - f_num_for_procs
2145   - f_ez_sed "<PROCESSES_QTT>" "$PROCESSES_QTT" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
2146   -
2147   - THREADS_QTT=0
2148   -
2149   - # NOTA: A estratégia abaixo foi utilizada pq o bash por padrão não
2150   - # permite cálculo de ponto flutuante! By Questor
2151   - THREADS_QTT=$(awk '{printf("%.8f\n",(($1*0.8)/$2))}' <<<" $PG_CONNECTIONS $PROCESSES_QTT ")
2152   -
2153   - # NOTA: A estratégia abaixo foi utilizada para arredondar o valor
2154   - # (remover o ponto flutuante)! By Questor
2155   - THREADS_QTT=${THREADS_QTT%\.*}
2156   -
2157   - # NOTE: Seta uma quantidade de threads adequada para o uWSGI! By Questor
2158   - f_div_section
2159   - f_get_usr_input "Enter the LBG - LBGenerator THREADS QUANTITY (numbers only, integers only).
2160   -Use empty for \"$THREADS_QTT\" (good for most cases)!
2161   -* Use at most 80% of the number of PostgreSQL connections divided by the number of uWSGI processes;
2162   -* Decrease the value if you have other applications using PostgreSQL;
2163   -* Higher values will cause LBG - LBGenerator and PostgreSQL services instability, crash and other unexpected results." 1
2164   - if [ -n "$GET_USR_INPUT_R" ] ; then
2165   - THREADS_QTT=$GET_USR_INPUT_R
2166   - fi
2167   -
2168   - f_ez_sed "<THREADS_QTT>" "$THREADS_QTT" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
2169   -
  2107 + f_procs_qtt 4
  2108 + f_ez_sed "<UWSGI_PROCESSES>" "$F_PROCS_QTT_R" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2109 + REQ_TIMEOUT=0
2170 2110 f_srv_memory
2171   -
2172   - # NOTA: A estratégia abaixo foi utilizada pq o bash por padrão não
2173   - # permite cálculo de ponto flutuante! By Questor
2174   - REQ_TIMEOUT=$(awk '{printf("%.8f\n",(($1/25550)*$2))}' <<<" $F_SRV_MEMORY_R $PROCESSES_QTT ")
2175   -
2176   - # NOTA: A estratégia abaixo foi utilizada para arredondar o valor
2177   - # (remover o ponto flutuante)! By Questor
2178   - REQ_TIMEOUT=${REQ_TIMEOUT%\.*}
2179   -
2180   - TOO_LOW_REQ_TIMEOUT=""
2181   - if (( ${REQ_TIMEOUT} < 150 )) ; then
2182   - TOO_LOW_REQ_TIMEOUT="
2183   -* WARNING: THE INSTALLER HAS CALCULATED A TOO LOW TIMEOUT VALUE FOR THIS SERVER. TIMEOUTS BELOW 150 SECONDS ARE CONSIDERED TOO LOW. CONSIDER USING A SERVER WITH MORE PROCESSORS AND/OR MEMORY."
  2111 + f_bytes_n_units "$F_SRV_MEMORY_R" "KB" "MB"
  2112 + F_SRV_MEMORY_R_IN_MB=$F_BYTES_N_UNITS_R
  2113 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "44"
  2114 + REQ_TIMEOUT=$F_GET_PERCENT_FROM_R
  2115 + TOO_LOW_REQ_TIMEOUT=" (good for most cases)!"
  2116 + if (( ${REQ_TIMEOUT} < 400 )) ; then
  2117 + TOO_LOW_REQ_TIMEOUT=".
  2118 +
  2119 +* WARNING: THE INSTALLER HAS CALCULATED A TOO LOW TIMEOUT VALUE FOR THIS SERVER. TIMEOUTS BELOW 400 SECONDS ARE CONSIDERED TOO LOW. CONSIDER USING A SERVER WITH MORE RAM!
  2120 +"
2184 2121 fi
2185 2122  
2186   - # NOTE: Seta um valor adequado para "request timeout" conforme a
2187   - # quantidade de núcleos e de memória da máquina! By Questor
  2123 + # NOTE: Calcula um valor de timeout conforme a quantidade de
  2124 + # memória RAM! By Questor
2188 2125 f_div_section
2189   - f_get_usr_input "Enter the LBG - LBGenerator REQUEST TIMEOUT (numbers only, integers only).
2190   -Use empty for \"$REQ_TIMEOUT\" (good for most cases and highly recommended)!
2191   -* Decrease the value if you have application performance and server instability problems;
2192   -* Higher values will cause server instability, crash and other unexpected results.$TOO_LOW_REQ_TIMEOUT" 1
  2126 + f_get_usr_input "Enter the HTTP REQUEST TIMEOUT (numbers only, integers only).
  2127 +Use empty for \"$REQ_TIMEOUT\"$TOO_LOW_REQ_TIMEOUT
  2128 +* Use a numeric value equivalent at most 44% of your server RAM in MB;
  2129 +* Decrease the value if you have other applications using your server;
  2130 +* Higher values will cause LBG - LBGenerator and PostgreSQL services instability, crash and other unexpected results." 1
2193 2131 if [ -n "$GET_USR_INPUT_R" ] ; then
2194 2132 REQ_TIMEOUT=$GET_USR_INPUT_R
2195 2133 fi
2196   -
2197   - f_ez_sed "<REQ_TIMEOUT>" "$REQ_TIMEOUT" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
2198   -
  2134 + f_ez_sed "<REQ_TIMEOUT>" "$REQ_TIMEOUT" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2135 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "150"
  2136 + UWSGI_POST_BUFFERING=$F_GET_PERCENT_FROM_R
  2137 + f_ez_sed "<UWSGI_POST_BUFFERING>" "$UWSGI_POST_BUFFERING" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2138 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "70"
  2139 + UWSGI_RELOAD_ON_AS=$F_GET_PERCENT_FROM_R
  2140 + f_ez_sed "<UWSGI_RELOAD_ON_AS>" "$UWSGI_RELOAD_ON_AS" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2141 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "65"
  2142 + UWSGI_RELOAD_ON_RSS=$F_GET_PERCENT_FROM_R
  2143 + f_ez_sed "<UWSGI_RELOAD_ON_RSS>" "$UWSGI_RELOAD_ON_RSS" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2144 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "85"
  2145 + UWSGI_EVIL_RELOAD_ON_AS=$F_GET_PERCENT_FROM_R
  2146 + f_ez_sed "<UWSGI_EVIL_RELOAD_ON_AS>" "$UWSGI_EVIL_RELOAD_ON_AS" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2147 + f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "75"
  2148 + UWSGI_EVIL_RELOAD_ON_RSS=$F_GET_PERCENT_FROM_R
  2149 + f_ez_sed "<UWSGI_EVIL_RELOAD_ON_RSS>" "$UWSGI_EVIL_RELOAD_ON_RSS" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
2199 2150 f_chk_by_path_hlp "$NGINX_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$NGINX_CONF_PATH/lbg.conf\"!"
2200 2151 F_BAK_MD_R=1
2201 2152 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
... ... @@ -2227,7 +2178,9 @@ Use empty for \&quot;$REQ_TIMEOUT\&quot; (good for most cases and highly recommended)!
2227 2178 elif [[ "$HTTP_SRV_WSGI" == "p" ]] ; then
2228 2179 eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini.pserver-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\""
2229 2180 f_ez_sed "<SQLA_POOL_SIZE>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2230   - f_ez_sed "<SQLALCHEMY_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2181 + f_ez_sed "<SQLA_POOL_SIZE_MAX_OVERFLOW>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2182 + f_ez_sed "<LBI_LBINDEX_URL>" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2183 + f_ez_sed "<SQLA_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2231 2184 f_ez_sed "<APP_ROOT_F>" "$APP_ROOT_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2232 2185 f_chk_by_path_hlp "$NGINX_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$NGINX_CONF_PATH/lbg.conf\"!"
2233 2186 F_BAK_MD_R=1
... ... @@ -2238,9 +2191,10 @@ Use empty for \&quot;$REQ_TIMEOUT\&quot; (good for most cases and highly recommended)!
2238 2191 \cp "$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf-ngix-pserve-dist" "$NGINX_CONF_PATH/lbg.conf"
2239 2192  
2240 2193 # NOTE: Determinar um número adequado de processos! By Questor
2241   - f_num_for_procs
  2194 + f_procs_qtt 2
  2195 +
2242 2196 UPSTREAM_LBG=""
2243   - for (( i=0; i < PROCESSES_QTT; i++ )) ; do
  2197 + for (( i=0; i < F_PROCS_QTT_R; i++ )) ; do
2244 2198 UPSTREAM_LBG=$UPSTREAM_LBG" server 127.0.0.1:500$i;\n"
2245 2199 done
2246 2200 f_ez_sed "<UPSTREAM_LBG>" "$UPSTREAM_LBG" "$NGINX_CONF_PATH/lbg.conf"
... ... @@ -2257,7 +2211,9 @@ Use empty for \&quot;$REQ_TIMEOUT\&quot; (good for most cases and highly recommended)!
2257 2211 f_ez_sed "<VE32_PATH>" "$BASE_INST_DIR_V/ve32" "$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi"
2258 2212 eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini.apache-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\""
2259 2213 f_ez_sed "<SQLA_POOL_SIZE>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2260   - f_ez_sed "<SQLALCHEMY_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2214 + f_ez_sed "<SQLA_POOL_SIZE_MAX_OVERFLOW>" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
  2215 + f_ez_sed "<LBI_LBINDEX_URL>" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini"
  2216 + f_ez_sed "<SQLA_URL>" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1
2261 2217 f_chk_by_path_hlp "$HTTPD_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$HTTPD_CONF_PATH/lbg.conf\"!"
2262 2218 F_BAK_MD_R=1
2263 2219 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
... ...
liblightbase.tar.gz
No preview for this file type
other-srcs-n-apps/lbg.conf-ngix-uwsgi-dist
... ... @@ -27,10 +27,10 @@ server {
27 27 proxy_set_header X-Real-IP $remote_addr;
28 28 proxy_temp_file_write_size 64k;
29 29 send_timeout 600; # Timeout 10 minutes.
30   - uwsgi_connect_timeout 1800; # Timeout 30 minutes.
  30 + uwsgi_connect_timeout 3600; # Timeout 60 minutes.
31 31 uwsgi_param SCRIPT_NAME "";
32 32 uwsgi_pass unix:///tmp/lbg.sock;
33   - uwsgi_read_timeout 1800; # Timeout 30 minutes.
34   - uwsgi_send_timeout 1800; # Timeout 30 minutes.
  33 + uwsgi_read_timeout 3600; # Timeout 60 minutes.
  34 + uwsgi_send_timeout 3600; # Timeout 60 minutes.
35 35 }
36 36 }
... ...
py-packs-LBGenerator.bash
... ... @@ -18,7 +18,7 @@ if [ -z &quot;$BASE_INST_DIR_V&quot; ] ; then
18 18 BASE_INST_DIR_V="/usr/local/lb"
19 19  
20 20 QUESTION_F="Enter the installation directory.
21   - Use empty for \"$BASE_INST_DIR_V\"!"
  21 +Use empty for \"$BASE_INST_DIR_V\"!"
22 22  
23 23 f_get_usr_input "$QUESTION_F" 1
24 24 QUESTION_F=""
... ...
py-packs-liblightbase.bash
... ... @@ -18,7 +18,7 @@ if [ -z &quot;$BASE_INST_DIR_V&quot; ] ; then
18 18 BASE_INST_DIR_V="/usr/local/lb"
19 19  
20 20 QUESTION_F="Enter the installation directory.
21   - Use empty for \"$BASE_INST_DIR_V\"!"
  21 +Use empty for \"$BASE_INST_DIR_V\"!"
22 22  
23 23 f_get_usr_input "$QUESTION_F" 1
24 24 QUESTION_F=""
... ...
py-packs-supervisor.bash
... ... @@ -18,7 +18,7 @@ if [ -z &quot;$BASE_INST_DIR_V&quot; ] ; then
18 18 BASE_INST_DIR_V="/usr/local/lb"
19 19  
20 20 QUESTION_F="Enter the installation directory.
21   - Use empty for \"$BASE_INST_DIR_V\"!"
  21 +Use empty for \"$BASE_INST_DIR_V\"!"
22 22  
23 23 f_get_usr_input "$QUESTION_F" 1
24 24 QUESTION_F=""
... ...
py-packs-uwsgi.bash
... ... @@ -18,7 +18,7 @@ if [ -z &quot;$BASE_INST_DIR_V&quot; ] ; then
18 18 BASE_INST_DIR_V="/usr/local/lb"
19 19  
20 20 QUESTION_F="Enter the installation directory.
21   - Use empty for \"$BASE_INST_DIR_V\"!"
  21 +Use empty for \"$BASE_INST_DIR_V\"!"
22 22  
23 23 f_get_usr_input "$QUESTION_F" 1
24 24 QUESTION_F=""
... ...