From efa5fe1239263ad49cbcdb0f0039e93b55686f36 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 17 Mar 2024 02:04:10 +0100 Subject: feat(users/Profpatsch/whatcd-resolver): add services & readme Gives a story for running both jaeger and the reverse proxy, and the program proper. `postgres` is still run from the client. Adds a little readme. Change-Id: I11185028541c0214e152fd76c9c72b7e2eb11122 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11171 Tested-by: BuildkiteCI Autosubmit: Profpatsch Reviewed-by: Profpatsch --- users/Profpatsch/.envrc | 2 +- users/Profpatsch/shell.nix | 11 +++++++++++ users/Profpatsch/whatcd-resolver/README.md | 21 +++++++++++++++++++++ users/Profpatsch/whatcd-resolver/build.ninja | 20 ++++++++++++++++++++ .../Profpatsch/whatcd-resolver/services/.gitignore | 3 +++ .../Profpatsch/whatcd-resolver/services/jaeger/run | 3 +++ .../whatcd-resolver/services/reverse-proxy/run | 2 ++ 7 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 users/Profpatsch/whatcd-resolver/README.md create mode 100644 users/Profpatsch/whatcd-resolver/build.ninja create mode 100644 users/Profpatsch/whatcd-resolver/services/.gitignore create mode 100755 users/Profpatsch/whatcd-resolver/services/jaeger/run create mode 100755 users/Profpatsch/whatcd-resolver/services/reverse-proxy/run (limited to 'users/Profpatsch') diff --git a/users/Profpatsch/.envrc b/users/Profpatsch/.envrc index 832afd26bd69..c91f923756f5 100644 --- a/users/Profpatsch/.envrc +++ b/users/Profpatsch/.envrc @@ -1,4 +1,4 @@ -if pass apps/declib/mastodon_access_token; then +if pass apps/declib/mastodon_access_token >/dev/null; then export DECLIB_MASTODON_ACCESS_TOKEN=$(pass apps/declib/mastodon_access_token) fi diff --git a/users/Profpatsch/shell.nix b/users/Profpatsch/shell.nix index f749c2e3439a..e04d7f195f82 100644 --- a/users/Profpatsch/shell.nix +++ b/users/Profpatsch/shell.nix @@ -4,6 +4,7 @@ let root = (import ../../. { }); in { pkgs ? root.third_party.nixpkgs, depot ? root, ... }: pkgs.mkShell { + buildInputs = [ pkgs.sqlite-interactive pkgs.sqlite-utils @@ -63,8 +64,18 @@ pkgs.mkShell { pkgs.postgresql_14 pkgs.nodejs pkgs.ninja + pkgs.s6 + pkgs.caddy + + (depot.nix.binify { + name = "nix-run"; + exe = depot.users.Profpatsch.nix-tools.nix-run; + }) ]; + DEPOT_ROOT = toString ./../..; + PROFPATSCH_ROOT = toString ./.; + WHATCD_RESOLVER_TOOLS = pkgs.linkFarm "whatcd-resolver-tools" [ { name = "pg_format"; diff --git a/users/Profpatsch/whatcd-resolver/README.md b/users/Profpatsch/whatcd-resolver/README.md new file mode 100644 index 000000000000..d1902e546a4f --- /dev/null +++ b/users/Profpatsch/whatcd-resolver/README.md @@ -0,0 +1,21 @@ +# whatcd-resolver + +To run: + +``` +ninja run-services +``` + +in one terminal (starts the background tasks) + +``` +ninja run +``` + +to start the server. It runs on `9092`. + +You need to be in the `nix-shell` in `./..`. + +You need to set the `pass` key `internet/redacted/api-keys/whatcd-resolver` to an API key for RED. + +You need to have a transmission-rpc-daemon listening on port `9091` (no auth, try ssh port forwarding lol). diff --git a/users/Profpatsch/whatcd-resolver/build.ninja b/users/Profpatsch/whatcd-resolver/build.ninja new file mode 100644 index 000000000000..ff6ba8df04d8 --- /dev/null +++ b/users/Profpatsch/whatcd-resolver/build.ninja @@ -0,0 +1,20 @@ + +builddir = .ninja + +outdir = ./output + +rule run-services + command = s6-svscan ./services + +rule run + command = execlineb -c '$ + importas -i DEPOT_ROOT DEPOT_ROOT $ + importas -i PROFPATSCH_ROOT PROFPATSCH_ROOT cd $$PROFPATSCH_ROOT $ + nix-run { $$DEPOT_ROOT -A users.Profpatsch.shortcuttable } cabal repl whatcd-resolver/ --repl-options "-e main" $ + ' + +build run-services: run-services + pool = console + +build run: run + pool = console diff --git a/users/Profpatsch/whatcd-resolver/services/.gitignore b/users/Profpatsch/whatcd-resolver/services/.gitignore new file mode 100644 index 000000000000..5cdb254e8c20 --- /dev/null +++ b/users/Profpatsch/whatcd-resolver/services/.gitignore @@ -0,0 +1,3 @@ +/.s6-svscan/ +/**/event/ +/**/supervise/ diff --git a/users/Profpatsch/whatcd-resolver/services/jaeger/run b/users/Profpatsch/whatcd-resolver/services/jaeger/run new file mode 100755 index 000000000000..41332f8bb61b --- /dev/null +++ b/users/Profpatsch/whatcd-resolver/services/jaeger/run @@ -0,0 +1,3 @@ +#!/usr/bin/env execlineb +importas -i DEPOT_ROOT DEPOT_ROOT +nix-run { $DEPOT_ROOT -A users.Profpatsch.jaeger -kK --builders '' } diff --git a/users/Profpatsch/whatcd-resolver/services/reverse-proxy/run b/users/Profpatsch/whatcd-resolver/services/reverse-proxy/run new file mode 100755 index 000000000000..7081b35f5ac3 --- /dev/null +++ b/users/Profpatsch/whatcd-resolver/services/reverse-proxy/run @@ -0,0 +1,2 @@ +#!/usr/bin/env execlineb +caddy reverse-proxy --from :9092 --to :9093 -- cgit 1.4.1