Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use latest stable nixpkgs globally #137

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ nix/nginx/logs/nginx.pid
*.bc
*.control
*.so
nginx.pid
80 changes: 0 additions & 80 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,86 +56,6 @@ select net.http_get('http://localhost:3000/projects');
-- * Connection #0 to host localhost left intact
```

### Reproducible setup for load testing

This will deploy a client and server on t3a.nano. You must have `supabase-dev` setup in `.aws/credentials`.

```bash
nixops create nix/deploy.nix -d pg_net

nixops deploy -d pg_net
# will take a while
```

Then you can connect on the client instance and do requests to the server instance through `pg_net`.

```bash
nixops ssh -d pg_net client

psql -U postgres

create extension pg_net;

select net.http_get('http://server');
# this the default welcome page of nginx on the server instance
# "server" is already included to /etc/hosts, so `curl http://server` will give the same result

# do some load testing
select net.http_get('http://server') from generate_series(1,1000);
# run `top` on another shell(another `nixops ssh -d pg_net client`) to check the worker behavior
```

#### Testing a slow response

Locally:

```bash
net-with-pg-12 psql

# takes some seconds to respond
select net.http_get('http://localhost:8080/slow-reply');
```

With the cloud NixOps setup:

```bash
nixops ssh -d pg_net client

# takes some seconds to respond
select net.http_get('http://server/slow-reply');
```

#### Destroying the setup

To destroy the instances:

```bash
nixops destroy -d pg_net --confirm
nixops delete -d pg_net
```

### Run Valgrind to check memory leaks

Start a postgres instance under valgrind.

```
valgrind-net-with-pg-12

# it should show this output:
# Connect to this db from another shell using the following command:
#
# psql -h <path> -U postgres

# connect to the db in another shell
psql -h <path> -U postgres

create extension pg_net;
select net.http_get('https://supabase.io');

# stop the db instance
# then see the valgrind results in "valgrindlog"
```

## Documentation

All public API must be documented. Building documentation requires python 3.6+
Expand Down
117 changes: 0 additions & 117 deletions nix/deploy.nix

This file was deleted.

2 changes: 1 addition & 1 deletion nix/nginx/conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
daemon off;
error_log /dev/stdout info;
pid ./nginx.pid;

events {}

Expand Down
13 changes: 9 additions & 4 deletions nix/nginxScript.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{ openresty, writeShellScriptBin } :
{ nginx, nginxModules, writeShellScriptBin } :

let
customNginx = nginx.override {
modules = [
nginxModules.echo
];
};
script = ''
set -euo pipefail

export PATH=${openresty}/bin:"$PATH"
export PATH=${customNginx}/bin:"$PATH"

trap 'killall openresty' sigint sigterm exit
trap 'killall nginx' sigint sigterm exit

openresty -p nix/nginx &
nginx -p nix/nginx -e stderr &

"$@"
'';
Expand Down
33 changes: 0 additions & 33 deletions nix/pgValgrindScript.nix

This file was deleted.

Loading