summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-09-13 12:25:45 +0200
committerBrian Picciano <mediocregopher@gmail.com>2022-09-13 12:25:45 +0200
commit5485984e05aebde22819adebfbd5ad51475a6c21 (patch)
treed3a8306755713e488ef23be507eafa3b0c574526
parentb1641d1af92eca6e475ea76aaed21a5dab0df185 (diff)
remove redis and circus
-rw-r--r--Makefile6
-rw-r--r--default.nix53
-rw-r--r--srv-dev-env.sh18
-rw-r--r--srv/default.nix8
-rw-r--r--srv/src/cfg/radix_client.go55
-rw-r--r--srv/src/cmd/mediocre-blog/main.go5
-rw-r--r--srv/src/go.mod9
-rw-r--r--srv/src/go.sum10
8 files changed, 14 insertions, 150 deletions
diff --git a/Makefile b/Makefile
index 72ff403..50795e3 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,10 @@ CONFIG = ./config.nix
entrypoint:
nix-build -A entrypoint \
- --arg baseConfig '(import ${CONFIG})'
+ --arg config '(import ${CONFIG})'
install:
- $$(nix-build -A install --arg baseConfig '(import ${CONFIG})')
+ $$(nix-build -A install --arg config '(import ${CONFIG})')
test:
$$(nix-build --no-out-link -A pkgs.bash)/bin/bash srv-dev-env.sh \
@@ -18,5 +18,5 @@ srv.dev-shell:
--command "cd srv/src; return"
srv.shell:
- nix-shell -A srv.shellWithBuild --arg baseConfig '(import ${CONFIG})' \
+ nix-shell -A srv.shellWithBuild --arg config '(import ${CONFIG})' \
--command 'cd srv/src; return'
diff --git a/default.nix b/default.nix
index f810fc6..98efd74 100644
--- a/default.nix
+++ b/default.nix
@@ -6,71 +6,26 @@
sha256 = "1ckzhh24mgz6jd1xhfgx0i9mijk6xjqxwsshnvq789xsavrmsc36";
}) {},
- baseConfig ? import ./config.nix,
- skipServices ? [],
+ config ? import ./config.nix,
}: rec {
pkgs = pkgsArg;
- config = baseConfig // {
- redisListenPath = "${config.runDir}/redis";
- };
-
srv = pkgs.callPackage (import ./srv) {
inherit config;
};
- redisCfg = pkgs.writeText "mediocre-blog-redisCfg" ''
- port 0
- unixsocket ${config.redisListenPath}
- daemonize no
- loglevel notice
- logfile ""
- appendonly yes
- appendfilename "appendonly.aof"
- dir ${config.dataDir}/redis
- '';
-
- redisBin = pkgs.writeScript "mediocre-blog-redisBin" ''
- #!/bin/sh
- mkdir -p ${config.dataDir}/redis
- exec ${pkgs.redis}/bin/redis-server ${redisCfg}
- '';
-
- srvCircusCfg = ''
- [watcher:srv]
- cmd = ${srv.bin}
- numprocesses = 1
- '';
-
- redisCircusCfg = ''
- [watcher:redis]
- cmd = ${redisBin}
- numprocesses = 1
- '';
-
- circusCfg = pkgs.writeText "mediocre-blog-circusCfg" ''
- [circus]
- endpoint = tcp://127.0.0.1:0
- pubsub_endpoint = tcp://127.0.0.1:0
-
- ${if (!builtins.elem "srv" skipServices) then srvCircusCfg else ""}
-
- ${if (!builtins.elem "redis" skipServices) then redisCircusCfg else ""}
- '';
entrypoint = pkgs.writeScript "mediocre-blog-entrypoint" ''
#!/bin/sh
set -e
- if [ ! -d ${config.runDir} ]; then
- mkdir -p ${config.runDir}
- fi
-
+ mkdir -p ${config.runDir}
mkdir -p ${config.dataDir}
- exec ${pkgs.circus}/bin/circusd ${circusCfg}
+
+ exec ${srv.bin}
'';
service = pkgs.writeText "mediocre-blog" ''
diff --git a/srv-dev-env.sh b/srv-dev-env.sh
index 2df9918..d41a96d 100644
--- a/srv-dev-env.sh
+++ b/srv-dev-env.sh
@@ -1,5 +1,6 @@
test_dir="$(mktemp -d)"
+trap "rm -rf $test_dir" EXIT
mkdir -p "$test_dir"/run
mkdir -p "$test_dir"/data
@@ -9,21 +10,6 @@ test_cfg="(import ./config.nix) // {
dataDir=\"${test_dir}/data\";
}"
-entrypoint=$(nix-build --no-out-link -A entrypoint \
- --arg baseConfig "$test_cfg" \
- --arg skipServices '["srv"]')
-
-$entrypoint &
-trap "kill $!; wait; rm -rf $test_dir" EXIT
-
-# NOTE this is a bit of a hack... the location of the redis socket's source of
-# truth is in default.nix, but it's not clear how to get that from there to
-# here, so we reproduce the calculation here.
-while [ ! -e $test_dir/run/redis ]; do
- echo "waiting for redis unix socket"
- sleep 1
-done
-
nix-shell -A srv.shell \
- --arg baseConfig "$test_cfg" \
+ --arg config "$test_cfg" \
"$@"
diff --git a/srv/default.nix b/srv/default.nix
index 95f35c5..e6216b3 100644
--- a/srv/default.nix
+++ b/srv/default.nix
@@ -19,10 +19,6 @@
export MEDIOCRE_BLOG_ML_SMTP_AUTH="${config.mlSMTPAuth}"
export MEDIOCRE_BLOG_ML_PUBLIC_URL="${config.publicURL}"
- # redis
- export MEDIOCRE_BLOG_REDIS_PROTO=unix
- export MEDIOCRE_BLOG_REDIS_ADDR="${config.redisListenPath}"
-
# pow
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
@@ -38,7 +34,7 @@
pname = "mediocre-blog-srv";
version = "dev";
src = ./src;
- vendorSha256 = "sha256:0kad8cyg9cd9v7m9l23jf27vkb5yfy9w89xfyrsyj7gd3q0l2yxq";
+ vendorSha256 = "sha256:1vazrrg8rs9n8x40c9r53h9qnyxw59xkp0aq7jl15fliigk6q0cr";
# disable tests
checkPhase = '''';
@@ -47,7 +43,7 @@
bin = writeScript "mediocre-blog-srv-bin" ''
#!${bash}/bin/bash
source ${init}
- exec ${build}/bin/mediocre-blog
+ exec ${build}/bin/mediocre-blog "$@"
'';
shell = stdenv.mkDerivation {
diff --git a/srv/src/cfg/radix_client.go b/srv/src/cfg/radix_client.go
deleted file mode 100644
index 55ff5d7..0000000
--- a/srv/src/cfg/radix_client.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package cfg
-
-import (
- "context"
- "fmt"
-
- "github.com/mediocregopher/mediocre-go-lib/v2/mctx"
- "github.com/mediocregopher/radix/v4"
-)
-
-// RadixClient is a single redis client which can be configured.
-type RadixClient struct {
- radix.Client
-
- proto, addr string
- poolSize int
-}
-
-// SetupCfg implement the cfg.Cfger interface.
-func (c *RadixClient) SetupCfg(cfg *Cfg) {
-
- cfg.StringVar(&c.proto, "redis-proto", "tcp", "Network protocol to connect to redis over, can be tcp or unix")
- cfg.StringVar(&c.addr, "redis-addr", "127.0.0.1:6379", "Address redis is expected to listen on")
- cfg.IntVar(&c.poolSize, "redis-pool-size", 5, "Number of connections in the redis pool to keep")
-
- cfg.OnInit(func(ctx context.Context) error {
- client, err := (radix.PoolConfig{
- Size: c.poolSize,
- }).New(
- ctx, c.proto, c.addr,
- )
-
- if err != nil {
- return fmt.Errorf(
- "initializing redis pool of size %d at %s://%s: %w",
- c.poolSize, c.proto, c.addr, err,
- )
- }
-
- c.Client = client
- return nil
- })
-}
-
-// Annotate implements mctx.Annotator interface.
-func (c *RadixClient) Annotate(a mctx.Annotations) {
- a["redisProto"] = c.proto
- a["redisAddr"] = c.addr
- a["redisPoolSize"] = c.poolSize
-}
-
-// Close cleans up the radix client.
-func (c *RadixClient) Close() error {
- return c.Client.Close()
-}
diff --git a/srv/src/cmd/mediocre-blog/main.go b/srv/src/cmd/mediocre-blog/main.go
index 4f8ba78..6b41e04 100644
--- a/srv/src/cmd/mediocre-blog/main.go
+++ b/srv/src/cmd/mediocre-blog/main.go
@@ -44,11 +44,6 @@ func main() {
httpParams.SetupCfg(cfg)
ctx = mctx.WithAnnotator(ctx, &httpParams)
- var radixClient cfgpkg.RadixClient
- radixClient.SetupCfg(cfg)
- defer radixClient.Close()
- ctx = mctx.WithAnnotator(ctx, &radixClient)
-
// initialization
err := cfg.Init(ctx)
diff --git a/srv/src/go.mod b/srv/src/go.mod
index 802cb89..4b047b9 100644
--- a/srv/src/go.mod
+++ b/srv/src/go.mod
@@ -3,17 +3,14 @@ module github.com/mediocregopher/blog.mediocregopher.com/srv
go 1.16
require (
- github.com/adrg/frontmatter v0.2.0
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21
github.com/emersion/go-smtp v0.15.0
github.com/gomarkdown/markdown v0.0.0-20220510115730-2372b9aa33e5
github.com/google/uuid v1.3.0
- github.com/gorilla/feeds v1.1.1 // indirect
- github.com/gorilla/websocket v1.4.2
- github.com/hashicorp/golang-lru v0.5.4 // indirect
+ github.com/gorilla/feeds v1.1.1
+ github.com/hashicorp/golang-lru v0.5.4
github.com/mattn/go-sqlite3 v1.14.8
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee
- github.com/mediocregopher/radix/v4 v4.0.0-beta.1.0.20210726230805-d62fa1b2e3cb
github.com/rubenv/sql-migrate v0.0.0-20210614095031-55d5740dbbcc
github.com/stretchr/testify v1.7.0
github.com/tilinna/clock v1.1.0
@@ -22,5 +19,5 @@ require (
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
- gopkg.in/yaml.v3 v3.0.1 // indirect
+ gopkg.in/yaml.v3 v3.0.1
)
diff --git a/srv/src/go.sum b/srv/src/go.sum
index 60fbd42..eb27d7f 100644
--- a/srv/src/go.sum
+++ b/srv/src/go.sum
@@ -1,12 +1,9 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
-github.com/adrg/frontmatter v0.2.0 h1:/DgnNe82o03riBd1S+ZDjd43wAmC6W35q67NHeLkPd4=
-github.com/adrg/frontmatter v0.2.0/go.mod h1:93rQCj3z3ZlwyxxpQioRKC1wDLto4aXHrbqIsnH9wmE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
@@ -68,8 +65,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
-github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
-github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
@@ -117,8 +112,6 @@ github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee h1:AWRuhgn7iumyhPuxKwed1F1Ri2dXMwxKfp5YIdpnQIY=
github.com/mediocregopher/mediocre-go-lib/v2 v2.0.0-beta.0.0.20220506011745-cbeee71cb1ee/go.mod h1:wOZVlnKYvIbkzyCJ3dxy1k40XkirvCd1pisX2O91qoQ=
-github.com/mediocregopher/radix/v4 v4.0.0-beta.1.0.20210726230805-d62fa1b2e3cb h1:7Y2vAC5q44VJzbBUdxRUEqfz88ySJ/6yXXkpQ+sxke4=
-github.com/mediocregopher/radix/v4 v4.0.0-beta.1.0.20210726230805-d62fa1b2e3cb/go.mod h1:ajchozX/6ELmydxWeWM6xCFHVpZ4+67LXHOTOVR0nCE=
github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@@ -167,7 +160,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/tilinna/clock v1.0.2/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao=
github.com/tilinna/clock v1.1.0 h1:6IQQQCo6KoBxVudv6gwtY8o4eDfhHo8ojA5dP0MfhSs=
github.com/tilinna/clock v1.1.0/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -252,9 +244,7 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=