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```sh
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}
28```
29
30## Testing collaborative features locally
31
32In one terminal, run Zed's collaboration server and the livekit dev server:
33
34```sh
35foreman start
36```
37
38In a second terminal, run two or more instances of Zed.
39
40```sh
41script/zed-local -2
42```
43
44This 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`.
45
46# Deployment
47
48We run two instances of collab:
49
50- Staging (https://staging-collab.zed.dev)
51- Production (https://collab.zed.dev)
52
53Both of these run on the Kubernetes cluster hosted in Digital Ocean.
54
55Deployment is triggered by pushing to the `collab-staging` (or `collab-production`) tag in Github. The best way to do this is:
56
57- `./script/deploy-collab staging`
58- `./script/deploy-collab production`
59
60You can tell what is currently deployed with `./script/what-is-deployed`.
61
62# Database Migrations
63
64To create a new migration:
65
66```sh
67./script/create-migration <name>
68```
69
70Migrations are run automatically on service start, so run `foreman start` again. The service will crash if the migrations fail.
71
72When you create a new migration, you also need to update the [SQLite schema](./migrations.sqlite/20221109000000_test_schema.sql) that is used for testing.