~edwargix/git.sr.ht

bfe62f1cc43bbadb30eeb9be269c4048e417bb69 — Thorben Günther 6 years ago 4c9b54b
Read redis host from cfg.
M config.example.ini => config.example.ini +3 -0
@@ 21,6 21,9 @@ source-url=https://git.sr.ht/~sircmpwn/srht
#
# A secret key to encrypt session cookies with
secret-key=CHANGEME
#
# The redis host url.
redis-host=

[mail]
#

M gitsrht-keys/main.go => gitsrht-keys/main.go +7 -2
@@ 122,7 122,7 @@ func fetchKeysFromMeta(logger *log.Logger, config ini.File,
	// Cache in Redis too
	cacheKey := fmt.Sprintf("git.sr.ht.ssh-keys.%s", b64key)
	cache := KeyCache{
		UserId: userId,
		UserId:   userId,
		Username: key.Owner.Username,
	}
	cacheBytes, err := json.Marshal(&cache)


@@ 148,7 148,12 @@ func main() {
	)
	// TODO: update key last used timestamp on meta.sr.ht

	redis := goredis.NewClient(&goredis.Options{Addr: "localhost:6379"})
	redisHost, ok := config.Get("sr.ht", "redis-host")
	if !ok {
		redisHost = "localhost"
	}
	redisHost += ":6379"
	redis := goredis.NewClient(&goredis.Options{Addr: redisHost})

	logf, err := os.OpenFile("/var/log/gitsrht-keys",
		os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)

M gitsrht-update-hook/post-update.go => gitsrht-update-hook/post-update.go +6 -1
@@ 160,7 160,12 @@ func postUpdate() {
		logger.Fatalf("Failed to fetch info from database: %v", err)
	}

	redis := goredis.NewClient(&goredis.Options{Addr: "localhost:6379"})
	redisHost, ok := config.Get("sr.ht", "redis-host")
	if !ok {
		redisHost = "localhost"
	}
	redisHost += ":6379"
	redis := goredis.NewClient(&goredis.Options{Addr: redisHost})
	for i, refname := range refs {
		var oldref, newref string
		var oldobj, newobj object.Object

M gitsrht-update-hook/update.go => gitsrht-update-hook/update.go +6 -1
@@ 22,7 22,12 @@ func update() {
	}
	logger.Printf("Running update for push %s", pushUuid)

	redis := goredis.NewClient(&goredis.Options{Addr: "localhost:6379"})
	redisHost, ok := config.Get("sr.ht", "redis-host")
	if !ok {
		redisHost = "localhost"
	}
	redisHost += ":6379"
	redis := goredis.NewClient(&goredis.Options{Addr: redisHost})
	redis.Set(fmt.Sprintf("update.%s.%s", pushUuid, refname),
		fmt.Sprintf("%s:%s", oldref, newref), 10*time.Minute)
}

M gitsrht/blueprints/api.py => gitsrht/blueprints/api.py +1 -1
@@ 10,9 10,9 @@ from gitsrht.webhooks import RepoWebhook
from io import BytesIO
from scmsrht.access import UserAccess
from scmsrht.blueprints.api import get_user, get_repo
from scmsrht.redis import redis
from srht.api import paginated_response
from srht.oauth import current_token, oauth
from srht.redis import redis
from srht.validation import Validation

data = Blueprint("api.data", __name__)

M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +1 -1
@@ 20,10 20,10 @@ from pygments.formatters import HtmlFormatter
from pygments.lexers import guess_lexer, guess_lexer_for_filename, TextLexer
from scmsrht.access import get_repo, get_repo_or_redir
from scmsrht.formatting import get_formatted_readme, get_highlighted_file
from scmsrht.redis import redis
from scmsrht.urls import get_clone_urls
from srht.config import cfg
from srht.markdown import markdown
from srht.redis import redis

repo = Blueprint('repo', __name__)


M gitsrht/git.py => gitsrht/git.py +1 -1
@@ 2,7 2,7 @@ from collections import deque
from datetime import datetime, timedelta, timezone
from pygit2 import Repository as GitRepository, Tag
from jinja2 import Markup, escape
from scmsrht.redis import redis
from srht.redis import redis
from stat import filemode
import pygit2
import json