kopia lustrzana https://codeberg.org/nmkj/audon
add example configs
rodzic
9ee523465b
commit
796fc79670
|
@ -0,0 +1,13 @@
|
|||
LOCAL_DOMAIN="audon.example.com"
|
||||
SESSION_SECRET="secret"
|
||||
DB_HOST="db:27017"
|
||||
DB_NAME="audon"
|
||||
DB_USER="mongo"
|
||||
DB_PASS="mongo"
|
||||
REDIS_HOST="redis:6379"
|
||||
REDIS_USER=""
|
||||
REDIS_PASS=""
|
||||
LIVEKIT_API_KEY="devkey"
|
||||
LIVEKIT_API_SECRET="secret"
|
||||
LIVEKIT_HOST="livekit.example.com"
|
||||
LIVEKIT_LOCAL_DOMAIN="livekit.example.com"
|
|
@ -102,6 +102,8 @@ web_modules/
|
|||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
.env.production
|
||||
!.env.*.example
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
@ -179,3 +181,8 @@ dist
|
|||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### Audon ###
|
||||
# Ignore all config files
|
||||
config/*
|
||||
!config/*-example.*
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
FROM node:18-bullseye AS build
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY audon-fe/ /workspace/
|
||||
|
||||
RUN npm install && npm run build
|
||||
|
||||
FROM golang:1.19-bullseye
|
||||
|
||||
WORKDIR /audon
|
||||
|
||||
COPY --from=build /workspace/dist /audon/audon-fe/dist
|
||||
COPY go.mod /audon/go.mod
|
||||
COPY go.sum /audon/go.sum
|
||||
|
||||
RUN go mod download
|
||||
|
||||
COPY *.go /audon/
|
||||
|
||||
RUN go build -a -v -o audon-bin .
|
||||
|
||||
ENV AUDON_ENV=production
|
||||
|
||||
ENTRYPOINT ["/audon/audon-bin"]
|
||||
EXPOSE 8100
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "audon-fe",
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0-dev",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
|
11
config.go
11
config.go
|
@ -54,9 +54,12 @@ func loadConfig(envname string) (*AppConfig, error) {
|
|||
envname = "development"
|
||||
}
|
||||
|
||||
// Set values in .env files to environment variables
|
||||
if err := godotenv.Load(".env." + envname + ".local"); err != nil {
|
||||
return nil, err
|
||||
// Loads environment variables in .env files if they exist
|
||||
localEnv := ".env." + envname + ".local"
|
||||
if _, err := os.Stat(localEnv); err == nil {
|
||||
if err := godotenv.Load(localEnv); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(".env"); err == nil {
|
||||
if err := godotenv.Load(".env"); err != nil {
|
||||
|
@ -120,7 +123,7 @@ func loadConfig(envname string) (*AppConfig, error) {
|
|||
return nil, err
|
||||
}
|
||||
lkURL := &url.URL{
|
||||
Scheme: "https",
|
||||
Scheme: "wss",
|
||||
Host: lkConf.LocalDomain,
|
||||
}
|
||||
lkConf.URL = lkURL
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# main TCP port for RoomService and RTC endpoint
|
||||
# for production setups, this port should be placed behind a load balancer with TLS
|
||||
port: 7880
|
||||
|
||||
rtc:
|
||||
# when set, LiveKit enable WebRTC ICE over TCP when UDP isn't available
|
||||
# this port *cannot* be behind load balancer or TLS, and must be exposed on the node
|
||||
# WebRTC transports are encrypted and do not require additional encryption
|
||||
# only 80/443 on public IP are allowed if less than 1024
|
||||
tcp_port: 7881
|
||||
# UDP ports to use for client traffic.
|
||||
# this port range should be open for inbound traffic on the firewall
|
||||
port_range_start: 50000
|
||||
port_range_end: 60000
|
||||
# when set to true, attempts to discover the host's public IP via STUN
|
||||
# this is useful for cloud environments such as AWS & Google where hosts have an internal IP
|
||||
# that maps to an external one
|
||||
use_external_ip: true
|
||||
|
||||
redis:
|
||||
address: redis:6379
|
||||
db: 1
|
||||
|
||||
turn:
|
||||
enabled: true
|
||||
domain: livekit-turn.example.com
|
||||
# optional (set only if not using external TLS termination)
|
||||
# cert_file: ""
|
||||
# key_file: ""
|
||||
# defaults to 5349 - if not using a load balancer, this must be set to 443
|
||||
tls_port: 5349
|
||||
# defaults to 3478 - recommended to 443 if not running HTTP3/QUIC server
|
||||
# only 53/80/443 are allowed if less than 1024
|
||||
# use h3://*** in Caddyfile if you use caddy as load balancer
|
||||
udp_port: 3478
|
||||
# set external_tl to true if using a L4 load balancer to terminate TLS. when enabled,
|
||||
# LiveKit expects unencrypted traffic on tls_port, and still advertise tls_port as a TURN/TLS candidate.
|
||||
external_tls: true
|
||||
|
||||
keys:
|
||||
# devkey: secret
|
||||
|
||||
webhook:
|
||||
# api_key: devkey
|
||||
urls:
|
||||
- https://audon.example.com/app/webhook
|
||||
|
||||
room:
|
||||
# allow rooms to be automatically created when participants join, defaults to true
|
||||
auto_create: false
|
||||
# number of seconds to leave a room open when it's empty
|
||||
empty_timeout: 300
|
||||
# limit number of participants that can be in a room, 0 for no limit
|
||||
max_participants: 0
|
||||
# limit size of room and participant's metadata, 0 for no limit
|
||||
max_metadata_size: 0
|
||||
|
||||
audio:
|
||||
# minimum level to be considered active, 0-127, where 0 is loudest
|
||||
# # defaults to 30
|
||||
active_level: 60
|
||||
# percentile to measure, a participant is considered active if it has exceeded the
|
||||
# ActiveLevel more than MinPercentile% of the time
|
||||
# # defaults to 40
|
||||
min_percentile: 20
|
||||
# frequency in ms to notify changes to clients, defaults to 500
|
||||
update_interval: 200
|
|
@ -0,0 +1,5 @@
|
|||
bind 127.0.0.1 ::1
|
||||
protected-mode yes
|
||||
port 6379
|
||||
timeout 0
|
||||
tcp-keepalive 300
|
|
@ -7,42 +7,60 @@ services:
|
|||
image: mongo:6
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: example
|
||||
ports:
|
||||
- 27017:27017
|
||||
MONGO_INITDB_ROOT_USERNAME: mongo
|
||||
MONGO_INITDB_ROOT_PASSWORD: mongo
|
||||
volumes:
|
||||
- db:/data/db
|
||||
- ./mongo:/data/db
|
||||
|
||||
mongo-express:
|
||||
image: mongo-express
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8081:8081
|
||||
environment:
|
||||
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
|
||||
# mongo-express:
|
||||
# image: mongo-express
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - 8081:8081
|
||||
# environment:
|
||||
# ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||
# ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||
# ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ['CMD', 'redis-cli', 'ping']
|
||||
ports:
|
||||
- 6379:6379
|
||||
command: redis-server /etc/redis.conf
|
||||
# ports:
|
||||
# - 6379:6379
|
||||
volumes:
|
||||
- redis:/data
|
||||
- ./redis:/data
|
||||
- ./config/redis.conf:/etc/redis.conf
|
||||
|
||||
redisinsight:
|
||||
image: redislabs/redisinsight:latest
|
||||
livekit:
|
||||
image: livekit/livekit-server:v1.3
|
||||
command: --config /etc/livekit.yaml
|
||||
restart: unless-stopped
|
||||
# network_mode: "host"
|
||||
ports:
|
||||
- 8001:8001
|
||||
- "7881:7881/tcp"
|
||||
- "50000-60000:50000-60000/udp"
|
||||
- "5349:5349/tcp"
|
||||
- "3478:3478/udp"
|
||||
depends_on:
|
||||
- redis
|
||||
volumes:
|
||||
- redisinsight:/db
|
||||
- ./config/livekit.yaml:/etc/livekit.yaml
|
||||
|
||||
volumes:
|
||||
db:
|
||||
redis:
|
||||
redisinsight:
|
||||
audon:
|
||||
build: .
|
||||
image: namekuji/audon
|
||||
env_file:
|
||||
- .env.production
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
|
||||
# redisinsight:
|
||||
# image: redislabs/redisinsight:latest
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - 8001:8001
|
||||
# volumes:
|
||||
# - redisinsight:/db
|
||||
|
|
31
server.go
31
server.go
|
@ -37,9 +37,9 @@ type (
|
|||
)
|
||||
|
||||
var (
|
||||
mastAppConfigBase *mastodon.AppConfig = nil
|
||||
mainDB *mongo.Database = nil
|
||||
mainValidator = validator.New()
|
||||
// mastAppConfigBase *mastodon.AppConfig = nil
|
||||
mainDB *mongo.Database = nil
|
||||
mainValidator = validator.New()
|
||||
mainConfig *AppConfig
|
||||
lkRoomServiceClient *lksdk.RoomServiceClient
|
||||
)
|
||||
|
@ -52,10 +52,13 @@ func init() {
|
|||
func main() {
|
||||
var err error
|
||||
|
||||
log.Println("Audon server started.")
|
||||
|
||||
// Load config from environment variables and .env
|
||||
log.Println("Reading .env files")
|
||||
mainConfig, err = loadConfig(os.Getenv("AUDON_ENV"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Fatalf("Failed reading .env files: %s\n", err.Error())
|
||||
}
|
||||
|
||||
// Setup Livekit RoomService Client
|
||||
|
@ -65,18 +68,19 @@ func main() {
|
|||
}
|
||||
lkRoomServiceClient = lksdk.NewRoomServiceClient(lkURL.String(), mainConfig.Livekit.APIKey, mainConfig.Livekit.APISecret)
|
||||
|
||||
backContext, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
backContext, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// Setup database client
|
||||
log.Println("Connecting to DB")
|
||||
dbClient, err := mongo.Connect(backContext, options.Client().ApplyURI(mainConfig.MongoURL.String()))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Fatalf("Failed connecting to DB: %s\n", err.Error())
|
||||
}
|
||||
mainDB = dbClient.Database(mainConfig.Database.Name)
|
||||
err = createIndexes(backContext)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Fatalf("Failed creating indexes: %s\n", err.Error())
|
||||
}
|
||||
|
||||
// Setup redis client
|
||||
|
@ -91,16 +95,13 @@ func main() {
|
|||
e := echo.New()
|
||||
defer e.Close()
|
||||
|
||||
t := &Template{
|
||||
templates: template.Must(template.ParseFiles("audon-fe/index.html", "audon-fe/dist/index.html")),
|
||||
}
|
||||
e.Renderer = t
|
||||
e.Validator = &CustomValidator{validator: mainValidator}
|
||||
|
||||
// Setup session middleware (currently Audon stores all client data in cookie)
|
||||
log.Println("Connecting to Redis")
|
||||
redisStore, err := redisstore.NewRedisStore(backContext, redisClient)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Fatalf("Failed connecting to Redis: %s\n", err.Error())
|
||||
}
|
||||
redisStore.KeyPrefix("session_")
|
||||
sessionOptions := sessions.Options{
|
||||
|
@ -140,8 +141,8 @@ func main() {
|
|||
|
||||
// use anonymous func to support graceful shutdown
|
||||
go func() {
|
||||
if err := e.Start(":1323"); err != nil && err != http.ErrServerClosed {
|
||||
e.Logger.Fatal("shutting down the server")
|
||||
if err := e.Start(":8100"); err != nil && err != http.ErrServerClosed {
|
||||
e.Logger.Fatalf("Shutting down the server: %s\n", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -154,7 +155,7 @@ func main() {
|
|||
e.Logger.Print("Attempting graceful shutdown")
|
||||
defer shutdownCancel()
|
||||
if err := e.Shutdown(shutdownCtx); err != nil {
|
||||
e.Logger.Fatal(err)
|
||||
e.Logger.Fatalf("Failed shutting down gracefully: %s\n", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue