From e8d9230dcea32e2d08331ac88ec37a413bf6e4fc Mon Sep 17 00:00:00 2001 From: Ruoqing He Date: Fri, 26 Jan 2024 16:41:06 +0800 Subject: [PATCH] Add developer guide on Arch Linux Modified `.env` to dictate users to set up `DB` related fields properly according to their actual setup. Signed-off-by: Ruoqing He --- .env | 21 ++++---- README.md | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 149 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 096ac9d1..05684d49 100644 --- a/.env +++ b/.env @@ -1,15 +1,17 @@ -## you should add the environment variable in .zshrc or other profile on production enviroment - -## Database connect and pool configuration -MEGA_DB_POSTGRESQL_URL = "postgres://${PG_USERNAME}:${PG_SECRET}@${PG_HOST}/mega" -MEGA_DB_MYSQL_URL = "mysql://${MYSQL_USERNAME}:${MYSQL_SECRET}@${MYSQL_HOST}/mega" - +# Fillin the following environment variables with values you set +DB = "" # {postgres, mysql} +DB_USERNAME = "" +DB_PASSWORD = "" +DB_HOST = "" + +MEGA_DB_POSTGRESQL_URL = "${DB}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/mega" +MEGA_DB_MYSQL_URL = "${DB}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/mega" MEGA_DB_MAX_CONNECTIONS = 32 MEGA_DB_MIN_CONNECTIONS = 16 -MEGA_DB_SQLX_LOGGING = false # Whether to enabling SQLx Log +MEGA_DB_SQLX_LOGGING = false # Whether to disabling SQLx Log -## Mega SSH key path +# Mega SSH key path MEGA_SSH_KEY = "/tmp/.mega/ssh" ## file storage configuration @@ -25,11 +27,10 @@ MEGA_BIG_OBJ_THRESHOLD_SIZE = 1024 # Unit KB. If the object file size exceeds th MEGA_INIT_DIRS = "projects,docs,third_parts" # init these repo directories in mega init command MEGA_IMPORT_DIRS = "third_parts" # Only import directory support multi-branch commit and tag, repo under regular directory only support main branch only -## Objects decode configuration GIT_INTERNAL_DECODE_CACHE_SIZE = 1000 # Maximum number of git objects in LRU cache GIT_INTERNAL_DECODE_STORAGE_BATCH_SIZE = 10000 # The maximum number of git object in a "INSERT" SQL database operation GIT_INTERNAL_DECODE_STORAGE_TQUEUE_SIZE = 10 # The maximum number of parallel insertion threads in the database operation queue -GIT_INTERNAL_DECODE_CACHE_TYEP = "lru" #{lru,redis} +GIT_INTERNAL_DECODE_CACHE_TYEP = "lru" # {lru,redis} REDIS_CONFIG = "redis://127.0.0.1:6379" ## Bazel build configuration diff --git a/README.md b/README.md index 61a12668..8452eaa5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ Centralized systems, despite their convenience and popularity, are not without t To address these challenges, there's a growing need for a decentralized open-source collaboration model. Such a model would enhance the freedom of communication among developers and strengthen their ownership and control over their code. By moving away from centralized systems, developers can ensure that their contributions and the direction of their projects are not unduly influenced by the policies or stability of a single platform. This shift towards decentralization is not just a technical necessity but a step towards preserving the ethos of open-source: collaboration, freedom, and community-driven development. -## Quick Started for developing and testing on MacOS +## Quick Start for developing and testing + +### MacOS 1. Install Rust on your MacOS machine. @@ -150,6 +152,140 @@ To address these challenges, there's a growing need for a decentralized open-sou $ git clone http://localhost:8000/projects/mega.git ``` +### Arch Linux + +1. Install Rust. + + ```bash + $ pacman -S rustup + $ rustup default stable + ``` + +2. Clone mega repository and build. + + ```bash + $ git clone https://github.com/web3infra-foundation/mega.git + $ cd mega + $ cargo build + ``` + +3. Install PostgreSQL and initialize database. + + 1. Install PostgreSQL. + + ```bash + $ pacman -S postgresql + # Switch to `postgres` user + $ sudo -i -u postgres + postgres $ initdb -D /var/lib/postgres/data -E utf8 # /Volumes/Data is where data will be stored + postgres $ exit + $ systemctl enable --now postgresql + ``` + + 2. Create database. + + ```bash + $ sudo -u postgres psql postgres + ``` + + ```sql + postgres=# \l + postgres=# DROP DATABASE IF EXISTS mega; + postgres=# CREATE DATABASE mega; + postgres=# \q + ``` + + 3. Import `mega/sql/postgres/pg_