This commit is contained in:
Jeffrey Picard 2022-01-15 20:34:52 +00:00
parent 07b81f6cb3
commit 2c0e4e88ba
2 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,36 @@
import os
import plyvel
from lbry.wallet.server.db.db import RocksDBStore
def main(db_dir: str):
old_path = os.path.join(db_dir, 'lbry-leveldb')
new_path = os.path.join(db_dir, 'lbry-rocksdb')
old_db = plyvel.DB(
old_path, create_if_missing=True, max_open_files=256,
write_buffer_size=64 * 1024 * 1024,
max_file_size=1024 * 1024 * 64, bloom_filter_bits=32
)
new_db = RocksDBStore(new_path, 64, 256)
try:
batch = []
append_batch = batch.append
cnt = 0
for k, v in old_db.iterator():
append_batch((k, v))
cnt += 1
if cnt % 100_000 == 0:
with new_db.write_batch() as batch_write:
batch_put = batch_write.put
for item in batch:
batch_put(*item)
batch.clear()
print(f"flushed {cnt} key/value items")
finally:
old_db.close()
new_db.close()
if __name__ == "__main__":
main('/mnt/sdb/wallet_server/_data/')

View file

@ -0,0 +1,61 @@
# FROM debian:10-slim
FROM python:3.7.12-slim-buster
ARG user=lbry
ARG db_dir=/database
ARG projects_dir=/home/$user
ARG DOCKER_TAG
ARG DOCKER_COMMIT=docker
ENV DOCKER_TAG=$DOCKER_TAG DOCKER_COMMIT=$DOCKER_COMMIT
RUN apt-get update && \
apt-get -y --no-install-recommends install \
wget \
tar unzip \
build-essential \
automake libtool \
pkg-config \
librocksdb-dev
# python3.7 \
# python3-dev \
# python3-pip \
# python3-wheel \
# python3-cffi \
# python3-setuptools && \
# update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
# rm -rf /var/lib/apt/lists/*
RUN groupadd -g 999 $user && useradd -m -u 999 -g $user $user
RUN mkdir -p $db_dir
RUN chown -R $user:$user $db_dir
COPY . $projects_dir
RUN chown -R $user:$user $projects_dir
USER $user
ENV PATH=/home/lbry/.local/bin:$PATH
WORKDIR $projects_dir
RUN python -m pip install --upgrade pip
RUN pip install lbry-rocksdb
RUN pip install uvloop
RUN make install
RUN python3 docker/set_build.py
RUN rm ~/.cache -rf
# entry point
ARG host=0.0.0.0
ARG tcp_port=50001
ARG daemon_url=https://lbry:lbry@192.99.151.178:9245/
VOLUME $db_dir
ENV TCP_PORT=$tcp_port
ENV HOST=$host
ENV DAEMON_URL=$daemon_url
ENV DB_DIRECTORY=$db_dir
ENV MAX_SESSIONS=1000000000
ENV MAX_SEND=1000000000000000000
ENV EVENT_LOOP_POLICY=uvloop
COPY ./docker/wallet_server_entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]