Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from zekroTJA/dev
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
zekroTJA authored May 11, 2019
2 parents 2e5e0b1 + dd5afbc commit 7a909d5
Show file tree
Hide file tree
Showing 41 changed files with 2,541 additions and 312 deletions.
16 changes: 16 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"esversion": 6,
"browser": true,
"jquery": true,
"strict": true,

"eqeqeq": true,
"eqnull": true,
"expr": true,
"funcscope": true,
"maxcomplexity": true,
"maxdepth": true,
"shadow": true,

"-W097": false
}
9 changes: 9 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tabWidth: 4
singleQuote: true
quoteProps: consistent
trailingComma: es5
bracketSpacing: true
arrowParens: always

requirePragma: true
insertPragma: true
8 changes: 8 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@
[[constraint]]
name = "github.com/gorilla/websocket"
version = "1.4.0"

[[constraint]]
branch = "master"
name = "github.com/zekroTJA/timedmap"

[[constraint]]
branch = "master"
name = "github.com/zekroTJA/ratelimit"
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $(BIN):
-X $(PACKAGE)/$(LDPAKAGE).AppVersion=$(TAG) \
-X $(PACKAGE)/$(LDPAKAGE).AppCommit=$(COMMIT) \
-X $(PACKAGE)/$(LDPAKAGE).Release=TRUE" \
$(CURDIR)/cmd/$(APPNAME)
$(CURDIR)/cmd/$(APPNAME)/*.go

PHONY += test
test:
Expand All @@ -74,7 +74,7 @@ lint:
PHONY += run
run:
$(GO) run -v \
$(CURDIR)/cmd/$(APPNAME) -c $(CONFIG)
$(CURDIR)/cmd/$(APPNAME)/*.go -c $(CONFIG)

PHONY += cleanup
cleanup:
Expand All @@ -85,6 +85,11 @@ cloc:
--exclude-dir=vendor,docs,public \
--exclude-lang=JSON,Markdown,YAML,XML,TOML,Sass ./

PHONY += release
release:
bash $(CURDIR)/scripts/bundle-release.sh


PHONY += help
help:
@echo "Available targets:"
Expand All @@ -104,4 +109,4 @@ help:
@echo ""


.PHONY: $(PHONY)
.PHONY: $(PHONY)
32 changes: 25 additions & 7 deletions cmd/yuri/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"os"
"os/signal"
"syscall"
"time"

"github.com/zekroTJA/yuri2/internal/logger"
"github.com/zekroTJA/yuri2/internal/static"

"github.com/zekroTJA/yuri2/internal/database/sqlite"

Expand All @@ -21,6 +23,8 @@ var (
func main() {
flag.Parse()

/// CUSTOMIZABLE DRIVER SECTION ///////////////////////////

// unmarshaler function for config
unmarshaler := yaml.Unmarshal
// marshaler function for preset config generation
Expand All @@ -31,6 +35,14 @@ func main() {
// database middleware
dbMiddleware := new(sqlite.SQLite)

///////////////////////////////////////////////////////////

// initializing teardown channel which will receive a
// signal when one of the listed signals was sent to the
// process or the program wants to exit itself by sending
// a custom signal into the channel.
teardownChan := make(chan os.Signal, 1)

// init Logger
inits.InitLogger()

Expand All @@ -46,7 +58,7 @@ func main() {
}()

// init Player
player := inits.InitPlayer(cfg.Lavalink, dbMiddleware)
player := inits.InitPlayer(cfg, dbMiddleware)

// init Bot
bot := inits.InitDiscordBot(cfg.Discord, dbMiddleware, player)
Expand All @@ -57,16 +69,22 @@ func main() {
}()

// init API
api := inits.InitAPI(cfg.API, dbMiddleware, bot.Session, player)
api := inits.InitAPI(cfg, dbMiddleware, bot.Session, player, teardownChan)
// close api exposure on exit
defer func() {
logger.Info("API :: shutting down")
api.Close()
}()

// block main go routine until one of the control
// signals below was catched
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc
// Block main thread until channel receives a teardown
// signal. If the signal equals the custom signal
// SigRestart which identifies a restart signal send
// by Yuri hinself, the routine will be blocked for
// 2 further seconds to ensure sending the response
// to the request properly.
signal.Notify(teardownChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
if sig := <-teardownChan; sig == static.SigRestart {
logger.Info("CORE :: blocking core routine for 2 seconds to ensure restart request response")
time.Sleep(2 * time.Second)
}
}
97 changes: 89 additions & 8 deletions config/example.config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,102 @@
# REST and web socket API configuration.
api:
# Enable or disable the web front end,
# REST and web socket API.
enable: false
# Address and port the REST and ws API
# will be exposed to.
address: :443
# The client ID of the Discord application
# of the bots account.
client_id: ""
# The client secret (NOT the bot token!) of
# the Discord application of the bots account.
client_secret: ""
# A list of discord IDs which will have access
# to the admin panel and to general admin
# functions.
admin_ids:
- 458352847312235407938
- 219834723749127398723
# This will be the address, from which the
# web interface will be accessed from.
# This is needed for redirecting from the
# discord OAuth2 application login.
public_address: https://yuri.example.com
# TLS configuration.
tls:
# Enable TLS encryption of REST and web socket
# exposure.
enable: true
# Cert file location.
cert_file: /etc/cert/example.com/example.com.cer
# Key file location.
key_file: /etc/cert/example.com/example.com.key

# Database configuration.
database:
# SQLite DSN.
dsn: file:yuri.db.sqlite3

# Discord bot configuration.
discord:
# The bot token of the Discord bot application.
token: ""
# General prefix which will always be accessable
# on all guilds. This should never be set to
# something like '.' or '-', because, the bot
# will ALWAYS listen to it also if the guild
# prefix was specified to something else.
general_prefix: y!
# The discord ID of the host of the bot.
# (Maybe yours ^^)
owner_id: ""
token: ""
# Roles names for specific permissions.
right_role_names:
# Role which blocks users from using
# the Yuri player.
blocked: YuriBlocked
# Role which allows users to use the
# Yuri player. If this is set to '' or
# '@everyone', everyone will be allowed
# to use Yuri except these who have the
# blocked role.
player: '@everyone'
# Status messages which will be displayed
# in the bots presence text.
status_shuffle:
# Shuffle delay.
delay: 10s
# Sttaus messages.
status:
- Yuri v.2!
- zekro.de
- github.com/zekroTJA/yuri2

database:
dsn: file:yuri.db.sqlite3
- Yuri v.2!
- zekro.de
- github.com/zekroTJA/yuri2

# Lavalink configuration.
lavalink:
# Address and port of the lavalink
# server. If on the same machine, just
# take localhost as address.
address: localhost:2333
# Password defined in the Lavalink
# configuration.
password: ""
sounds_location: ""
# Sound file locations.
# The locatiosn will be scanned for sounds
# NOT recursively. Multiple directories will
# be treated like one, merged directory.
sounds_locations:
- /var/yurisounds
- /home/zekro/myyurisounds

# Miscellaneous configuration.
misc:
# Log level.
# 0 - critical
# 1 - errors
# 2 - warnings
# 3 - notice
# 4 - info
# 5 - debug
log_level: 4
Loading

0 comments on commit 7a909d5

Please sign in to comment.