Skip to content

Commit

Permalink
Merge pull request #10 from moul/dev/moul/wip
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Jul 6, 2020
2 parents 54c1fed + f701ce9 commit 60f033e
Show file tree
Hide file tree
Showing 50 changed files with 755 additions and 170 deletions.
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ PRE_BUMPDEPS_STEPS += gen.suma

include rules.mk

COMPILEDAEMON_OPTIONS ?= -exclude-dir=.git -color=true -build=go\ install -build-dir=./cmd/sgtm

.PHONY: run
run: install
sgtm --dev-mode --enable-server --enable-discord run
run: _devserver generate
CompileDaemon $(COMPILEDAEMON_OPTIONS) -command="sgtm --dev-mode --enable-server --enable-discord run"

.PHONY: run-discord
run-discord: install
sgtm --dev-mode --enable-discord run
run-discord: _devserver generate
CompileDaemon $(COMPILEDAEMON_OPTIONS) -command="sgtm --dev-mode --enable-discord run"

.PHONY: run-server
run-server: install
sgtm --dev-mode --enable-server run
run-server: _devserver generate
CompileDaemon $(COMPILEDAEMON_OPTIONS) -command="sgtm --dev-mode --enable-server run"

.PHONY: packr
packr:
Expand Down Expand Up @@ -87,3 +88,7 @@ clean: generate.clean

.PHONY: regenerate
regenerate: gen.clean generate

.PHONY: _devserver
_devserver:
go install github.com/githubnemo/CompileDaemon
7 changes: 7 additions & 0 deletions api/sgtm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,10 @@ message Post {
Comment = 2;
}
}

/// Internal

message Session {
string DiscordAccessToken = 1;
string DiscordID = 2;
}
12 changes: 10 additions & 2 deletions cmd/sgtm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func app(args []string) error {
rootFlags.DurationVar(&svcOpts.ServerRequestTimeout, "server-request-timeout", svcOpts.ServerRequestTimeout, "server request timeout")
rootFlags.DurationVar(&svcOpts.ServerShutdownTimeout, "server-shutdown-timeout", svcOpts.ServerShutdownTimeout, "server shutdown timeout")
rootFlags.BoolVar(&svcOpts.ServerWithPprof, "server-with-pprof", svcOpts.ServerWithPprof, "enable pprof on HTTP server")
rootFlags.StringVar(&svcOpts.DiscordClientID, "discord-client-id", svcOpts.DiscordClientID, "discord client ID (oauth)")
rootFlags.StringVar(&svcOpts.DiscordClientSecret, "discord-client-secret", svcOpts.DiscordClientSecret, "discord client secret (oauth)")
rootFlags.StringVar(&svcOpts.JWTSigningKey, "jwt-signing-key", svcOpts.JWTSigningKey, "HMAC secret to sign JWT tokens")

root := &ffcli.Command{
FlagSet: rootFlags,
Expand All @@ -74,6 +77,7 @@ func app(args []string) error {
func runCmd(ctx context.Context, _ []string) error {
// init
rand.Seed(srand.Secure())
svcOpts.Context = ctx

// bearer
// FIXME: TODO
Expand Down Expand Up @@ -111,6 +115,7 @@ func runCmd(ctx context.Context, _ []string) error {
if err != nil {
return err
}
svcOpts.Snowflake = sfn
err = sgtm.DBInit(db, sfn)
if err != nil {
return err
Expand All @@ -120,8 +125,11 @@ func runCmd(ctx context.Context, _ []string) error {
// init service
var svc sgtm.Service
{
//svcOpts.Context = ctx
svc = sgtm.New(db, svcOpts)
var err error
svc, err = sgtm.New(db, svcOpts)
if err != nil {
return err
}
defer svc.Close()
}

Expand Down
9 changes: 6 additions & 3 deletions config.txt.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## Discord
#enable-discord true
#discord-token REPLACE_ME
#discord-admin-channel REPLACE_ME
discord-token REPLACE_ME
discord-admin-channel REPLACE_ME
discord-client-id REPLACE_ME
discord-client-secret REPLACE_ME

## Server
enable-server true
#enable-server true
server-bind 0.0.0.0:7676
jwt-signing-key REPLACE_ME
4 changes: 2 additions & 2 deletions gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package tools

import (
_ "github.com/alta/protopatch/patch"
_ "github.com/githubnemo/CompileDaemon"
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"
Expand Down
Loading

0 comments on commit 60f033e

Please sign in to comment.