README.md

 1# Zed Server
 2
 3This crate is what we run at https://collab.zed.dev.
 4
 5It contains our back-end logic for collaboration, to which we connect from the Zed client via a websocket after authenticating via https://zed.dev, which is a separate repo running on Vercel.
 6
 7# Local Development
 8
 9## Database setup
10
11Before you can run the collab server locally, you'll need to set up a zed Postgres database.
12
13```
14script/bootstrap
15```
16
17This script will set up the `zed` Postgres database, and populate it with some users. It requires internet access, because it fetches some users from the GitHub API.
18
19The script will create several _admin_ users, who you'll sign in as by default when developing locally. The GitHub logins for the default users are specified in the `seed.default.json` file.
20
21To use a different set of admin users, create `crates/collab/seed.json`.
22
23```json
24{
25  "admins": ["yourgithubhere"],
26  "channels": ["zed"],
27  "number_of_users": 20
28}
29```
30
31## Testing collaborative features locally
32
33In one terminal, run Zed's collaboration server and the livekit dev server:
34
35```
36foreman start
37```
38
39In a second terminal, run two or more instances of Zed.
40
41```
42script/zed-local -2
43```
44
45This script starts one to four instances of Zed, depending on the `-2`, `-3` or `-4` flags. Each instance will be connected to the local `collab` server, signed in as a different user from `seed.json` or `seed.default.json`.
46
47# Deployment
48
49We run two instances of collab:
50
51- Staging (https://staging-collab.zed.dev)
52- Production (https://collab.zed.dev)
53
54Both of these run on the Kubernetes cluster hosted in Digital Ocean.
55
56Deployment is triggered by pushing to the `collab-staging` (or `collab-production`) tag in Github. The best way to do this is:
57
58- `./script/deploy-collab staging`
59- `./script/deploy-collab production`
60
61You can tell what is currently deployed with `./script/what-is-deployed`.
62
63# Database Migrations
64
65To create a new migration:
66
67```
68./script/create-migration <name>
69```
70
71Migrations are run automatically on service start, so run `foreman start` again. The service will crash if the migrations fail.
72
73When you create a new migration, you also need to update the [SQLite schema](./migrations.sqlite/20221109000000_test_schema.sql) that is used for testing.