diff --git a/Dockerfile b/Dockerfile index c89d473..76facce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,9 @@ RUN chown -R mysql:mysql /build/data /var/lib/mysql/data ADD ./docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh ADD assets/utils/*.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/*.sh +RUN mkdir -p /usr/local/bin/migrations +ADD ./scripts/migrations/*.sh /usr/local/bin/migrations +RUN chmod a+x /usr/local/bin/migrations/* # remove to we can manually handle db initalization RUN rm -rf /var/lib/mysql/ diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index a5e41e2..4cf0fe0 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -8,18 +8,6 @@ _term() { kill -TERM "$frontend_process" 2>/dev/null } -# Record system memory info to read for bitcoin auto config -SYSTEM_MEM_INFO=$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo) -SYSTEM_MEM_FILE=/root/start9/system_mem_info - -if [ -f "$SYSTEM_MEM_FILE" ] -then - echo "$SYSTEM_MEM_INFO" > "$SYSTEM_MEM_FILE" -else - touch /root/start9/system_mem_info - echo "$SYSTEM_MEM_INFO" > "$SYSTEM_MEM_FILE" -fi - # FRONTEND SETUP LIGHTNING_DETECTED_PORT=9735 diff --git a/manifest.yaml b/manifest.yaml index c17754d..a7a8af8 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,6 +1,6 @@ id: mempool title: Mempool -version: 3.0.0.2 +version: 3.0.0.3 release-notes: | * Sets bounds on RAM used for the mempool * Update the latest pool data from the Mempool repository on startup @@ -166,8 +166,32 @@ backup: io-format: yaml migrations: from: - "*": + "<2.3.1.4": type: script + ">=2.3.1.4 <2.5.0": + type: script + ">=2.5.0 <=3.0.0.2": + type: docker + image: main + system: false + entrypoint: /usr/local/bin/migrations/gt_2_5_0_lt_3_0_0_2.sh + args: ["from"] + io-format: json + mounts: + main: /root + inject: false to: - "*": + "<2.3.1.4": + type: script + ">=2.3.1.4 <2.5.0": type: script + ">=2.5.0 <3.0.0.2": + type: docker + image: main + system: false + entrypoint: /usr/local/bin/migrations/gt_2_5_0_lt_3_0_0_2.sh + args: ["to"] + io-format: json + mounts: + main: /root + inject: false diff --git a/scripts/migrations/gt_2_5_0_lt_3_0_0_2.sh b/scripts/migrations/gt_2_5_0_lt_3_0_0_2.sh new file mode 100644 index 0000000..d9ba442 --- /dev/null +++ b/scripts/migrations/gt_2_5_0_lt_3_0_0_2.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -ea + +# up migration +if [ $1 = "from" ]; then + # Record system memory info to read for bitcoin auto config + SYSTEM_MEM_INFO=$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo) + SYSTEM_MEM_FILE=/root/start9/system_mem_info + + if [ -f "$SYSTEM_MEM_FILE" ] + then + echo "$SYSTEM_MEM_INFO" > "$SYSTEM_MEM_FILE" + else + touch /root/start9/system_mem_info + echo "$SYSTEM_MEM_INFO" > "$SYSTEM_MEM_FILE" + fi + echo '{"configured": true }' + + exit 0 +# down migration +elif [ $1 = "to" ]; then + rm /root/start9/system_mem_info + echo '{"configured": true }' + exit 0 +else + echo "FATAL: Invalid argument: {from, to}. Migration failed." >&2 + exit 1 +fi \ No newline at end of file diff --git a/scripts/procedures/dependencies.ts b/scripts/procedures/dependencies.ts index 9c379cd..146bbd9 100644 --- a/scripts/procedures/dependencies.ts +++ b/scripts/procedures/dependencies.ts @@ -23,18 +23,15 @@ async function getSystemMemoryLimit(effects: T.Effects) { // convert kb to mb const memMB = parseInt(memdata) / 1000 return Math.round(memMB / 6) - } catch (e) { - effects.info(e) - // default recommended is 300MB + } catch (_e) { + // recommended default is 300MB return 300 } } export const dependencies: T.ExpectedExports.dependencies = { bitcoind: { - // deno-lint-ignore require-await async check(effects, configInput) { - effects.info("check bitcoind"); const config = matchBitcoindConfig.unsafeCast(configInput); if (!config.rpc.enable) { return { error: "Must have RPC enabled" }; @@ -48,23 +45,21 @@ export const dependencies: T.ExpectedExports.dependencies = { "Pruning must be disabled to use Bitcoin Core.", }; } - const limit = await getSystemMemoryLimit(effects) - if (limit > 300 && config.advanced.mempool.maxmempool >= limit) { + const limit = await getSystemMemoryLimit(effects); + if (limit > 300 && config.advanced.mempool.maxmempool > limit) { return { error: "In order to safely run Mempool, Bitcoin Core's \"maxmempool\" size cannot exceed 1/6 of the system RAM" } } return { result: null }; }, - // deno-lint-ignore require-await async autoConfigure(effects, configInput) { - effects.info("autoconfigure bitcoind"); const config = matchBitcoindConfig.unsafeCast(configInput); config.rpc.enable = true; config.txindex = true; config.advanced.pruning.mode = "disabled"; - const limit = await getSystemMemoryLimit(effects) - if (limit > 300 && config.advanced.mempool.maxmempool >= limit) { + const limit = await getSystemMemoryLimit(effects); + if (limit > 300 && config.advanced.mempool.maxmempool > limit) { config.advanced.mempool.maxmempool = limit } return { result: config };