Monibuca provides database support functionality, allowing database configuration and usage in both global settings and plugins.
Database can be configured in global settings using these fields:
global:
dsn: "database connection string"
dbType: "database type"Each plugin can have its own database configuration:
pluginName:
dsn: "database connection string"
dbType: "database type"-
When the server starts, if
dsnis configured, it attempts to connect to the database -
After successful connection, the following models are automatically migrated:
- User table
- PullProxy table
- PushProxy table
- StreamAliasDB table
-
If login is enabled (
Admin.EnableLogin = true), users are created or updated based on the configuration file -
If no users exist in the database, a default admin account is created:
- Username: admin
- Password: admin
- Role: admin
- During plugin initialization, the plugin's
dsnconfiguration is checked - If the plugin's
dsnmatches the global configuration, the global database connection is used - If the plugin configures a different
dsn, a new database connection is created - If the plugin implements the Recorder interface, the RecordStream table is automatically migrated
The global database can be accessed through the Server instance:
server.DBPlugins can access their database through their instance:
plugin.DB- Database connection failures will disable related functionality
- Plugins using independent databases need to manage their own database connections
- Database migration failures will cause plugins to be disabled
- It's recommended to reuse the global database connection when possible to avoid creating too many connections
Stores user information, including:
- Username: User's name
- Password: User's password
- Role: User's role (admin/user)
Stores pull proxy configurations
Stores push proxy configurations
Stores stream alias configurations
Stores recording-related information (only created when plugin implements Recorder interface)