mirror of
https://github.com/waku-org/nwaku-compose.git
synced 2025-02-20 02:58:25 +00:00
Moving shm script to own script
This commit is contained in:
parent
0b434ce789
commit
f457fb686b
14
README.md
14
README.md
@ -47,7 +47,7 @@ Note that if you just want to relay traffic (not publish), you don't need one.
|
||||
./register_rln.sh
|
||||
```
|
||||
|
||||
### 💽 2. Select storage size
|
||||
### 💽 2. Select DB Parameters
|
||||
|
||||
Waku runs a PostgreSQL Database to store messages from the network and serve them to other peers.
|
||||
To prevent the database to grow indefinitely, you need to select how much disk space to allocate.
|
||||
@ -63,6 +63,18 @@ Or select your own value. For example, `50GB`:
|
||||
echo "STORAGE_SIZE=50GB" >> .env
|
||||
```
|
||||
|
||||
Depending on your machine's memory, it may be worth allocating more memory to the Postgres container to ensure heavy queries are served:
|
||||
|
||||
```shell
|
||||
./set_postgres_shm.sh
|
||||
```
|
||||
|
||||
Or select your own value manually, for example, `4g`:
|
||||
|
||||
```shell
|
||||
echo "POSTGRES_SHM=4g" >> .env
|
||||
```
|
||||
|
||||
### 🖥️ 3. Start your node
|
||||
|
||||
Start all processes: nwaku node, database and grafana for metrics. Your [RLN](https://rate-limiting-nullifier.github.io/rln-docs/what_is_rln.html) membership is loaded into nwaku under the hood.
|
||||
|
28
set_postgres_shm.sh
Executable file
28
set_postgres_shm.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# check if POSTGRES_SHM is already specified
|
||||
if [ -f "./.env" ]; then
|
||||
. ./.env
|
||||
fi
|
||||
|
||||
if [ -n "$POSTGRES_SHM" ]; then
|
||||
>&2 echo "POSTGRES_SHM is specified in .env file, doing nothing"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set PostgreSQL container Shared Memory value
|
||||
TOTAL_MEM_MB=$(free -m|grep Mem| awk '{ print $2 }')
|
||||
if [ "${TOTAL_MEM_MB}" -ge 4096 ]; then
|
||||
# Allocate 2GB of Shared Memory for Postgres if machine has more than 4GB RAM
|
||||
POSTGRES_SHM='2g'
|
||||
else
|
||||
# Allocate 1GB of Shared Memory for Postgres
|
||||
POSTGRES_SHM='1g'
|
||||
fi
|
||||
|
||||
>&2 echo "Setting PostgreSQL container SHM to ${POSTGRES_SHM}"
|
||||
if [ "$1" = "echo-value" ]; then
|
||||
echo ${POSTGRES_SHM}
|
||||
else
|
||||
echo "POSTGRES_SHM=${POSTGRES_SHM}" >> .env
|
||||
fi
|
@ -56,19 +56,6 @@ if [ -f "./.env" ]; then
|
||||
. ./.env
|
||||
fi
|
||||
|
||||
# Set PostgreSQL container Shared Memory value
|
||||
if [ -z "${POSTGRES_SHM}" ]; then
|
||||
TOTAL_MEM_MB=$(free -m|grep Mem| awk '{ print $2 }')
|
||||
if [ "${TOTAL_MEM_MB}" -ge 4096 ]; then
|
||||
# Allocate 2GB of Shared Memory for Postgres if machine has more than 4GB RAM
|
||||
POSTGRES_SHM='2g'
|
||||
echo "Setting PostgreSQL container SHM to ${POSTGRES_SHM}"
|
||||
echo "POSTGRES_SHM=${POSTGRES_SHM}" >> .env
|
||||
fi
|
||||
else
|
||||
>&2 echo "POSTGRES_SHM is already specified in .env file"
|
||||
fi
|
||||
|
||||
if [ -n "$STORAGE_SIZE" ]; then
|
||||
>&2 echo "STORAGE_SIZE is specified in .env file, doing nothing"
|
||||
exit 0
|
||||
|
@ -66,18 +66,29 @@ if [ -z "$STORAGE_SIZE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echocol "...."
|
||||
echocol "Selecting a SHM for Postgres..."
|
||||
POSTGRES_SHM=$(./set_postgres_shm.sh echo-value)
|
||||
|
||||
if [ -z "$POSTGRES_SHM" ]; then
|
||||
echo "Error encountered when estimating postgres container shm, exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echocol "...."
|
||||
echocol "The following parameters will be saved to your .env file. Press ENTER to confirm or quit with CONTROL-C to abort:"
|
||||
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
|
||||
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
|
||||
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
|
||||
STORAGE_SIZE=$STORAGE_SIZE"
|
||||
STORAGE_SIZE=$STORAGE_SIZE
|
||||
POSTGRES_SHM=$POSTGRES_SHM"
|
||||
read foo
|
||||
|
||||
echo "RLN_RELAY_ETH_CLIENT_ADDRESS='$RLN_RELAY_ETH_CLIENT_ADDRESS'
|
||||
ETH_TESTNET_KEY=$ETH_TESTNET_KEY
|
||||
RLN_RELAY_CRED_PASSWORD='$RLN_RELAY_CRED_PASSWORD'
|
||||
STORAGE_SIZE=$STORAGE_SIZE" > ./.env
|
||||
STORAGE_SIZE=$STORAGE_SIZE
|
||||
POSTGRES_SHM=$POSTGRES_SHM" > ./.env
|
||||
|
||||
SUDO=""
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user