Add support for specifying the path for chat db. Closes #61
This commit is contained in:
parent
26e4092295
commit
a8fe8a1cfa
@ -15,18 +15,19 @@ import (
|
|||||||
var Config *config
|
var Config *config
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
IPFS ipfs `yaml:"ipfs"`
|
ChatDatabaseFilePath string `yaml:"chatDatabaseFile"`
|
||||||
PublicHLSPath string `yaml:"publicHLSPath"`
|
DisableWebFeatures bool `yaml:"disableWebFeatures"`
|
||||||
PrivateHLSPath string `yaml:"privateHLSPath"`
|
EnableDebugFeatures bool `yaml:"-"`
|
||||||
VideoSettings videoSettings `yaml:"videoSettings"`
|
FFMpegPath string `yaml:"ffmpegPath"`
|
||||||
Files files `yaml:"files"`
|
Files files `yaml:"files"`
|
||||||
FFMpegPath string `yaml:"ffmpegPath"`
|
IPFS ipfs `yaml:"ipfs"`
|
||||||
WebServerPort int `yaml:"webServerPort"`
|
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
||||||
S3 s3 `yaml:"s3"`
|
PrivateHLSPath string `yaml:"privateHLSPath"`
|
||||||
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
PublicHLSPath string `yaml:"publicHLSPath"`
|
||||||
VersionInfo string `yaml:"-"`
|
S3 s3 `yaml:"s3"`
|
||||||
DisableWebFeatures bool `yaml:"disableWebFeatures"`
|
VersionInfo string `yaml:"-"`
|
||||||
EnableDebugFeatures bool `yaml:"-"`
|
VideoSettings videoSettings `yaml:"videoSettings"`
|
||||||
|
WebServerPort int `yaml:"webServerPort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstanceDetails defines the user-visible information about this particular instance.
|
// InstanceDetails defines the user-visible information about this particular instance.
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
|
|
||||||
//Setup sets up the chat server
|
//Setup sets up the chat server
|
||||||
func Setup(listener models.ChatListener) {
|
func Setup(listener models.ChatListener) {
|
||||||
|
setupPersistence()
|
||||||
|
|
||||||
messages := []models.ChatMessage{}
|
messages := []models.ChatMessage{}
|
||||||
clients := make(map[string]*Client)
|
clients := make(map[string]*Client)
|
||||||
addCh := make(chan *Client)
|
addCh := make(chan *Client)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gabek/owncast/config"
|
||||||
"github.com/gabek/owncast/models"
|
"github.com/gabek/owncast/models"
|
||||||
"github.com/gabek/owncast/utils"
|
"github.com/gabek/owncast/utils"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
@ -13,11 +14,11 @@ import (
|
|||||||
|
|
||||||
var _db *sql.DB
|
var _db *sql.DB
|
||||||
|
|
||||||
func init() {
|
func setupPersistence() {
|
||||||
file := "./chat.db"
|
file := config.Config.ChatDatabaseFilePath
|
||||||
// Create empty DB file if it doesn't exist.
|
// Create empty DB file if it doesn't exist.
|
||||||
if !utils.DoesFileExists(file) {
|
if !utils.DoesFileExists(file) {
|
||||||
log.Traceln("Creating new chat history database...")
|
log.Traceln("Creating new chat history database at", file)
|
||||||
|
|
||||||
_, err := os.Create(file)
|
_, err := os.Create(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
7
main.go
7
main.go
@ -28,6 +28,7 @@ func main() {
|
|||||||
log.Infoln(getVersion())
|
log.Infoln(getVersion())
|
||||||
|
|
||||||
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
|
configFile := flag.String("configFile", "config.yaml", "Config File full path. Defaults to current folder")
|
||||||
|
chatDbFile := flag.String("chatDatabase", "", "Path to the chat database file.")
|
||||||
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
|
enableDebugOptions := flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
|
||||||
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
|
enableVerboseLogging := flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
|
||||||
|
|
||||||
@ -48,6 +49,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
config.Config.EnableDebugFeatures = *enableDebugOptions
|
config.Config.EnableDebugFeatures = *enableDebugOptions
|
||||||
|
|
||||||
|
if *chatDbFile != "" {
|
||||||
|
config.Config.ChatDatabaseFilePath = *chatDbFile
|
||||||
|
} else if config.Config.ChatDatabaseFilePath == "" {
|
||||||
|
config.Config.ChatDatabaseFilePath = "chat.db"
|
||||||
|
}
|
||||||
|
|
||||||
// starts the core
|
// starts the core
|
||||||
if err := core.Start(); err != nil {
|
if err := core.Start(); err != nil {
|
||||||
log.Error("failed to start the core package")
|
log.Error("failed to start the core package")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user