~evanj/e3

f07259c77881216ff62e998d3125c07041119356 — Evan J 1 year, 3 months ago 14b25a4
Fix(cache.go): Don't error out when item is too large for cache.
5 files changed, 33 insertions(+), 12 deletions(-)

M .build.yml
M go.mod
M go.sum
M internal/cache/cache.go
M makefile
M .build.yml => .build.yml +23 -7
@@ 1,15 1,31 @@
image: ubuntu/latest
arch: amd64
image: debian/testing
packages:
  - golang
  - make
  - golang
sources:
  - https://git.sr.ht/~evanj/e3
secrets:
  - 0154a9d3-f2c9-4ee2-8102-7c4c92492149
tasks:
  - build: |
      export PATH=$PATH:$HOME/go/bin
      cd e3
      touch .env
      make builddeps
      export PATH="$PATH:$HOME/go/bin"
      make gen
      make build
      make setup gen build
      if [ `git branch | head -n 1 | awk '{print$5}' | sed 's/)//g' | xargs -I X bash -c "git log --pretty=oneline origin/master | head -n 1 | grep X" | wc -l` == "1" ]; then
        echo "deploying to production"
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "sudo mysqldump e3 > \$(mktemp --suffix .e3.datbase.backup.sql)"'
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "rm ~/e3/e3 2>/dev/null"'
        scp -o 'StrictHostKeyChecking=no' e3 evan@140.82.14.80:~/e3
        scp -r -o 'StrictHostKeyChecking=no' static evan@140.82.14.80:~/e3
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "sudo systemctl restart e3"'
      elif [ `git branch | head -n 1 | awk '{print$5}' | sed 's/)//g' | xargs -I X bash -c "git log --pretty=oneline origin/tip | head -n 1 | grep X" | wc -l` == "1" ]; then
        echo "deploying to tip"
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "sudo mysqldump e3_tip > \$(mktemp --suffix .e3.tip.datbase.backup.sql)"'
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "rm ~/e3.tip/e3 2>/dev/null"'
        scp -o 'StrictHostKeyChecking=no' e3 evan@140.82.14.80:~/e3.tip
        scp -r -o 'StrictHostKeyChecking=no' static evan@140.82.14.80:~/e3.tip
        ssh -o 'StrictHostKeyChecking=no' evan@140.82.14.80 'bash -c "sudo systemctl restart e3.tip"'
      else 
        echo "not deploying"
      fi

M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module git.sr.ht/~evanj/e3
go 1.13

require (
	git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa // indirect
	git.sr.ht/~evanj/embed v0.0.0-20200702023953-8a902e4e7e94 // indirect
	git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997
	github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
	github.com/davecgh/go-spew v1.1.1 // indirect

M go.sum => go.sum +2 -0
@@ 1,5 1,7 @@
git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa h1:gpQ2a3/AYs0o1F/kg2V2GIUIS8pPkvoSlJPZCbF9Mvw=
git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa/go.mod h1:o3sadZPJeN9scjfsbpsABLF2nNr6qUqMMkGLfCCsILc=
git.sr.ht/~evanj/embed v0.0.0-20200702023953-8a902e4e7e94 h1:uvmXsjtUvWzL3n3ghDejB3r6HV1Bl/EaDPmqs/F3cyA=
git.sr.ht/~evanj/embed v0.0.0-20200702023953-8a902e4e7e94/go.mod h1:o3sadZPJeN9scjfsbpsABLF2nNr6qUqMMkGLfCCsILc=
git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997 h1:fdAj8fR4mpS/OAvetjc9Xn96ZYrnJcQpbn/AUG0jihs=
git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997/go.mod h1:40791KVgThT97CT6mTsF4NUNPeX2BAVlsuH1RiiSrAs=
github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg=

M internal/cache/cache.go => internal/cache/cache.go +4 -1
@@ 116,7 116,10 @@ func (c *Cache) toCache(key string, data *db.Data) (*db.Data, error) {

	if err := c.mc.Add(&memcache.Item{Key: key, Value: bytes}); err != nil {
		c.log.Println("failed to add item to memcache", key, data.URL, err)
		return nil, err
		// File is likely too big for current memcached settings.
		// Don't error.
		// return nil, err
		return data, nil
	}

	c.log.Println("successfully added item to memcache", key, data.URL)

M makefile => makefile +3 -3
@@ 3,10 3,10 @@ export $(shell sed 's/=.*//' .env)

BIN=e3

all: builddeps vendor gen build
all: setup vendor gen build

builddeps:
	go get git.sr.ht/~evanj/embed
setup:
	go get git.sr.ht/~evanj/embed/cmd/embed

vendor: go.mod go.sum
	go mod vendor