modified all start scripts with better memory settings, improved auto-fix script and added settings.json update to temporarily remove archive settings for network issues potentially related, will remove archiveInterval in the future. Also modified start-qortal.sh to add comprehensive checks for Qortal running and auto-fix script, and run both if not existing/running.

This commit is contained in:
crowetic 2024-11-22 20:48:16 -08:00
parent 67a279cd2a
commit dd1c1e0fc0
7 changed files with 220 additions and 21 deletions

View File

@ -33,7 +33,23 @@ fi
# Limits Java JVM stack size and maximum heap usage. # Limits Java JVM stack size and maximum heap usage.
# Comment out for bigger systems, e.g. non-routers # Comment out for bigger systems, e.g. non-routers
# or when API documentation is enabled # or when API documentation is enabled
JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=60 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof -Xlog:gc*:file=gc.log:time,uptime,level,tags" #JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=60 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof -Xlog:gc*:file=gc.log:time,uptime,level,tags"
JVM_MEMORY_ARGS="
-Xms2600m \
-Xmx2600m \
-Xss1024k \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=./heapdump.hprof \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=300 \
-XX:InitiatingHeapOccupancyPercent=75 \
-XX:ParallelGCThreads=4 \
-XX:ConcGCThreads=2 \
-XX:G1HeapRegionSize=32m \
-XX:MaxTenuringThreshold=10 \
-XX:+AlwaysPreTouch
"
# Although java.net.preferIPv4Stack is supposed to be false # Although java.net.preferIPv4Stack is supposed to be false
# by default in Java 11, on some platforms (e.g. FreeBSD 12), # by default in Java 11, on some platforms (e.g. FreeBSD 12),

View File

@ -62,16 +62,17 @@ check_for_pi() {
if [ "$(uname -m | grep 'armv7l')" != "" ]; then if [ "$(uname -m | grep 'armv7l')" != "" ]; then
echo "${WHITE} 32bit ARM detected, using ARM 32bit compatible modified start script${NC}\n" echo "${WHITE} 32bit ARM detected, using ARM 32bit compatible modified start script${NC}\n"
PI_32_DETECTED=true PI_32_DETECTED=true
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/start-modified-memory-args.sh
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-cron
crontab auto-fix-cron
chmod +x start-modified-memory-args.sh
mv start-modified-memory-args.sh ~/qortal/start.sh
check_qortal
else else
echo "${WHITE} 64bit ARM detected, proceeding accordingly...${NC}\n" echo "${WHITE} 64bit ARM detected, proceeding accordingly...${NC}\n"
PI_64_DETECTED=true PI_64_DETECTED=true
fi fi
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/start-modified-memory-args.sh
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-cron
crontab auto-fix-cron
chmod +x start-modified-memory-args.sh
mv start-modified-memory-args.sh ~/qortal/start.sh
check_qortal
else else
echo "${YELLOW} Not a Raspberry pi machine, continuing...${NC}\n" echo "${YELLOW} Not a Raspberry pi machine, continuing...${NC}\n"
check_memory check_memory
@ -469,6 +470,43 @@ force_bootstrap() {
update_script update_script
} }
potentially_update_settings() {
BACKUP_FILE=~/backups/qortal-settings/settings-$(date +%Y%m%d%H%M%S).json
# Create backup folder if not exists and backup settings.json
echo "${GREEN}Creating backup directory ~/backups/qortal-settings...${NC}"
mkdir -p ~/backups/qortal-settings
echo "Backing up settings to ${BACKUP_FILE}..."
cp ~/qortal/settings.json "${BACKUP_FILE}"
SETTINGS_FILE=~/qortal/settings.json
echo "Checking for archivingPause setting..."
if grep -q '"archivingPause"' "${SETTINGS_FILE}"; then
echo "archivingPause exists... updating value..."
if command -v jq &> /dev/null; then
echo "jq exists, using jq to modify setting..."
jq '.archivingPause = 999999999999' "${SETTINGS_FILE}" > settings.tmp && mv settings.tmp "${SETTINGS_FILE}"
else
echo "jq doesn't exist, modifying with sed..."
sed -i 's/"archivingPause"[[:space:]]*:[[:space:]]*[0-9]*/"archivingPause": 999999999999/' "${SETTINGS_FILE}"
fi
else
echo "archivingPause doesn't exist, adding..."
if command -v jq &> /dev/null; then
echo "jq exists, adding with jq..."
jq '.archivingPause = 999999999999' "${SETTINGS_FILE}" > settings.tmp && mv settings.tmp "${SETTINGS_FILE}"
else
echo "jq doesn't exist, adding with sed..."
sed -i 's/}$/,"archivingPause": 999999999999}/' "${SETTINGS_FILE}"
fi
fi
echo "Settings check complete! Exiting..."
exit
}
update_script() { update_script() {
echo "${YELLOW}Updating script to newest version and backing up old one...${NC}\n" echo "${YELLOW}Updating script to newest version and backing up old one...${NC}\n"
mkdir -p ~/qortal/new-scripts mkdir -p ~/qortal/new-scripts
@ -484,7 +522,8 @@ update_script() {
rm -rf ~/auto_fix_updated rm -rf ~/auto_fix_updated
echo "${YELLOW} Auto-fix script run complete.${NC}\n" echo "${YELLOW} Auto-fix script run complete.${NC}\n"
sleep 5 sleep 5
exit potentially_update_settings
} }
initial_update initial_update

View File

@ -1,10 +1,11 @@
{ {
"apiDocumentationEnabled":true, "apiDocumentationEnabled":true,
"maxPeers": 77, "maxPeers": 88,
"minOutboundPeers": 22, "minOutboundPeers": 22,
"maxNetworkThreadPoolSize": 660, "maxNetworkThreadPoolSize": 600,
"repositoryConnectionPoolSize": 1880, "repositoryConnectionPoolSize": 1220,
"apiWhitelistEnabled": false, "apiWhitelistEnabled": false,
"blockCacheSize": 333, "blockCacheSize": 33,
"archiveInterval": 999999999999,
"apiRestricted": false "apiRestricted": false
} }

View File

@ -33,7 +33,22 @@ fi
# Limits Java JVM stack size and maximum heap usage. # Limits Java JVM stack size and maximum heap usage.
# Comment out for bigger systems, e.g. non-routers # Comment out for bigger systems, e.g. non-routers
# or when API documentation is enabled # or when API documentation is enabled
JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=40 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof" #JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=40 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof"
JVM_MEMORY_ARGS="
-Xms6000m \
-Xmx6000m \
-Xss2048k \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=./heapdump.hprof \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=300 \
-XX:InitiatingHeapOccupancyPercent=55 \
-XX:ParallelGCThreads=4 \
-XX:ConcGCThreads=2 \
-XX:G1HeapRegionSize=32m \
-XX:MaxTenuringThreshold=10 \
-XX:+AlwaysPreTouch
"
# Although java.net.preferIPv4Stack is supposed to be false # Although java.net.preferIPv4Stack is supposed to be false
# by default in Java 11, on some platforms (e.g. FreeBSD 12), # by default in Java 11, on some platforms (e.g. FreeBSD 12),

View File

@ -34,13 +34,29 @@ fi
# Comment out for bigger systems, e.g. non-routers # Comment out for bigger systems, e.g. non-routers
# or when API documentation is enabled # or when API documentation is enabled
# Uncomment (remove '#' sign) line below if your system has less than 12GB of RAM for optimal RAM defaults # Uncomment (remove '#' sign) line below if your system has less than 12GB of RAM for optimal RAM defaults
JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=40 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof" #JVM_MEMORY_ARGS="-XX:MaxRAMPercentage=40 -XX:+UseG1GC -Xss512k -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./heapdump.hprof"
JVM_MEMORY_ARGS="
-Xms8000m \
-Xmx8000m \
-Xss4096k \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=./heapdump.hprof \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=300 \
-XX:InitiatingHeapOccupancyPercent=35 \
-XX:ParallelGCThreads=4 \
-XX:ConcGCThreads=2 \
-XX:G1HeapRegionSize=32m \
-XX:MaxTenuringThreshold=10 \
-XX:+AlwaysPreTouch
"
# Although java.net.preferIPv4Stack is supposed to be false # Although java.net.preferIPv4Stack is supposed to be false
# by default in Java 11, on some platforms (e.g. FreeBSD 12), # by default in Java 11, on some platforms (e.g. FreeBSD 12),
# it is overridden to be true by default. Hence we explicitly # it is overridden to be true by default. Hence we explicitly
# set it to false to obtain desired behaviour. # set it to false to obtain desired behaviour.
nohup nice -n 2 java \ nohup nice -n 12 java \
-Djava.net.preferIPv4Stack=false \ -Djava.net.preferIPv4Stack=false \
${JVM_MEMORY_ARGS} \ ${JVM_MEMORY_ARGS} \
-jar qortal.jar \ -jar qortal.jar \

View File

@ -33,13 +33,28 @@ fi
# Limits Java JVM stack size and maximum heap usage. # Limits Java JVM stack size and maximum heap usage.
# Comment out for bigger systems, e.g. non-routers # Comment out for bigger systems, e.g. non-routers
# or when API documentation is enabled # or when API documentation is enabled
JVM_MEMORY_ARGS="-Xss1256k -Xmx1750m" #JVM_MEMORY_ARGS="-Xss1256k -Xms1750m -Xmx1750m"
JVM_MEMORY_ARGS="
-Xms1750m \
-Xmx1750m \
-Xss1212k \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=./heapdump.hprof \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=300 \
-XX:InitiatingHeapOccupancyPercent=50 \
-XX:ParallelGCThreads=4 \
-XX:ConcGCThreads=2 \
-XX:G1HeapRegionSize=32m \
-XX:MaxTenuringThreshold=10 \
-XX:+AlwaysPreTouch
"
# Although java.net.preferIPv4Stack is supposed to be false # Although java.net.preferIPv4Stack is supposed to be false
# by default in Java 11, on some platforms (e.g. FreeBSD 12), # by default in Java 11, on some platforms (e.g. FreeBSD 12),
# it is overridden to be true by default. Hence we explicitly # it is overridden to be true by default. Hence we explicitly
# set it to false to obtain desired behaviour. # set it to false to obtain desired behaviour.
nohup nice -n 5 java \ nohup nice -n 15 java \
-Djava.net.preferIPv4Stack=false \ -Djava.net.preferIPv4Stack=false \
${JVM_MEMORY_ARGS} \ ${JVM_MEMORY_ARGS} \
-jar qortal.jar \ -jar qortal.jar \

View File

@ -1,5 +1,102 @@
#!/bin/bash #!/bin/bash
cd qortal
./stop.sh QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
sleep 3 GUI_START="~/.config/autostart/start-qortal.desktop"
./start.sh
if [ -f "${GUI_START}" ]; then
echo "Qortal is set up to start via GUI, waiting 2 minutes for Qortal to start..."
sleep 120
echo "Checking if Qortal is running..."
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
if [ -n "${QORTAL_RUNNING}" ]; then
echo "Qortal is already running...not starting Qortal..."
exit
else
echo "Qortal did not start after 2 minutes...waiting another 90 seconds..."
sleep 90
echo "Attempting to start Qortal again..."
bash ~/qortal/start.sh
echo "Waiting 120 seconds..."
sleep 120
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
if [ -n "${QORTAL_RUNNING}" ]; then
echo "Qortal running, exiting..."
exit
else
echo "Qortal is still not running... checking for auto-fix-visible GUI..."
if [ -f ~/.config/autostart/auto-fix-visible* ]; then
echo "auto-fix-visible exists, waiting for auto-fix script to run..."
exit 1
else
echo "auto-fix-visible doesn't exist... running auto-fix script manually..."
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
chmod +x auto-fix-qortal.sh
echo "Executing auto-fix-qortal.sh..."
./auto-fix-qortal.sh
exit
fi
fi
fi
else
echo "Qortal is not set up to start via GUI...Checking if Qortal is running after a 90-second wait..."
sleep 90
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
if [ -z "${QORTAL_RUNNING}" ]; then
echo "Qortal is not running..."
echo "Attempting to start Qortal..."
bash ~/qortal/start.sh
echo "Start script has executed, awaiting Qortal start..."
sleep 90
echo "Checking if Qortal is running..."
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
if [ -n "${QORTAL_RUNNING}" ]; then
echo "Qortal has started successfully! Exiting script..."
exit
else
echo "Qortal did not start...force-killing Java and starting again..."
killall -9 java
bash ~/qortal/start.sh
echo "Qortal start script has been executed..."
if crontab -l | grep -q '#.*auto-fix-qortal.sh'; then
echo "'auto-fix-qortal.sh' is commented out in crontab. Manually executing auto-fix script..."
echo "Grabbing the newest version of auto-fix script..."
cd
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
chmod +x auto-fix-qortal.sh
echo "Executing auto-fix-qortal.sh..."
./auto-fix-qortal.sh
exit
elif crontab -l | grep -q '[^#]*auto-fix-qortal.sh'; then
echo "'auto-fix-qortal.sh' is active in crontab...auto-fix script should run automatically within 7 min from reboot..."
echo "Checking if machine has just booted..."
UPTIME=$(awk '{print int($1)}' /proc/uptime)
if [ "${UPTIME}" -ge 420 ]; then
echo "Machine has been online longer than 7 min, assuming auto-fix script would have run if it were supposed to..."
echo "Running auto-fix script manually..."
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
chmod +x auto-fix-qortal.sh
echo "Executing auto-fix-qortal.sh..."
./auto-fix-qortal.sh
exit
else
echo "Machine has been online less than 7 min, allowing auto-fix script to run on its own..."
exit
fi
else
echo "'auto-fix-qortal.sh' does not exist in crontab."
echo "Assuming it was removed accidentally..."
echo "Running auto-fix script manually, and setting it up to run automatically..."
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
chmod +x auto-fix-qortal.sh
echo "Executing auto-fix-qortal.sh..."
./auto-fix-qortal.sh
exit
fi
fi
else
echo "Qortal is running, exiting script..."
exit
fi
fi