-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified `.env` to dictate users to set up `DB` related fields properly according to their actual setup. Signed-off-by: Ruoqing He <[email protected]>
- Loading branch information
1 parent
57c9df0
commit e8d9230
Showing
2 changed files
with
149 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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_<time>_init.sql` to `mega`. | ||
|
||
```bash | ||
$ cd mega/sql/postgres | ||
$ psql mega < pg_<time>__init.sql | ||
``` | ||
|
||
4. Craeate user and grant privileges. | ||
|
||
```sql | ||
postgres=# DROP USER IF EXISTS mega; | ||
postgres=# CREATE USER mega WITH ENCRYPTED PASSWORD 'rustgit'; | ||
postgres=# GRANT ALL PRIVILEGES ON DATABASE mega TO mega; | ||
``` | ||
|
||
```bash | ||
$ psql mega -c "GRANT ALL ON ALL TABLES IN SCHEMA public to mega;" | ||
$ psql mega -c "GRANT ALL ON ALL SEQUENCES IN SCHEMA public to mega;" | ||
$ psql mega -c "GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to mega;" | ||
``` | ||
|
||
4. Install redis. | ||
|
||
```bash | ||
$ pacman -S redis | ||
$ systemctl enable --now redis | ||
``` | ||
|
||
5. Config `.env`. | ||
|
||
```ini | ||
# If you followed the installation guide, you can use below URL directly, comment it the otherwise. | ||
MEGA_DB_POSTGRESQL_URL = "postgres://mega:[email protected]/mega" | ||
# If you changed any of the username, password or host, you will need to uncomment the following line and replace the placeholders manually. | ||
#MEGA_DB_POSTGRESQL_URL = "postgres://<username>:<password>@127.0.0.1/<db_name (or host)>" | ||
MEGA_DB_MAX_CONNECTIONS = 32 | ||
MEGA_DB_MIN_CONNECTIONS = 16 | ||
|
||
MEGA_DB_SQLX_LOGGING = false # Whether to disabling SQLx Log | ||
|
||
## file storage configuration | ||
MEGA_OBJ_STORAGR_TYPE = "LOCAL" # LOCAL or REMOTE | ||
MEGA_OBJ_LOCAL_PATH = "/tmp/.mega" # This configuration is used to set the local path of the project storage | ||
|
||
MEGA_BIG_OBJ_THRESHOLD_SIZE = 1024 # Unit KB. If the object file size exceeds the threshold value, it will be handled by file storage instead of the database. | ||
|
||
## Init directory configuration | ||
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 | ||
|
||
|
||
GIT_INTERNAL_DECODE_CACHE_SIZE = 100 # Maximum number of git objects in LRU cache | ||
GIT_INTERNAL_DECODE_STORAGE_BATCH_SIZE = 1000 # The maximum number of git object in a "INSERT" SQL database operation | ||
GIT_INTERNAL_DECODE_STORAGE_TQUEUE_SIZE = 1 # The maximum number of parallel insertion threads in the database operation queue | ||
GIT_INTERNAL_DECODE_CACHE_TYEP = "redis" # {lru,redis} | ||
REDIS_CONFIG = "redis://127.0.0.1:6379" | ||
|
||
## Bazel build config, you can use service like buildfarm to enable RBE(remote build execution) | ||
# you can refer to https://bazelbuild.github.io/bazel-buildfarm/docs/quick_start/ for more details about remote executor | ||
BAZEL_BUILD_ENABLE = false # leave true if you want to trigger bazel build in each push process | ||
BAZEL_BUILDP_PATH = "/tmp/.mega/bazel_build_projects" # Specify a temporary directory to build the project with bazel | ||
BAZEL_REMOTE_EXECUTOR = "grpc://localhost:8980" # If enable the remote executor, please fillin the remote executor address, or else leave empty if you want to build by localhost. | ||
BAZEL_GIT_CLONE_URL = "http://localhost:8000" # Tell bazel to clone the project from the specified git url | ||
``` | ||
|
||
6. Init Mega. | ||
|
||
```bash | ||
$ cd mega | ||
$ cargo run init | ||
``` | ||
|
||
7. Start Mega server. | ||
|
||
```bash | ||
# Start a single https server | ||
$ cargo run service https | ||
# Or Start multiple server | ||
$ cargo run service start http ssh p2p | ||
``` | ||
|
||
8. Test `git push` and `git clone` | ||
|
||
```bash | ||
$ cd mega | ||
$ git remote add local http://localhost:8000/projects/mega.git | ||
$ git push local main | ||
$ cd /tmp | ||
$ git clone http://localhost:8000/projects/mega.git | ||
``` | ||
|
||
## Contributing | ||
|
||
The mega project relies on community contributions and aims to simplify getting started. To develop Mega, clone the repository, then install all dependencies and initialize the database schema, run the test suite and try it out locally. Pick an issue, make changes, and submit a pull request for community review. | ||
|
@@ -161,4 +297,4 @@ More information on contributing to Mega is available in the [Contributing Guide | |
Mega is licensed under this Licensed: | ||
|
||
- MIT LICENSE ( [LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) | ||
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) | ||
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) |