-
Notifications
You must be signed in to change notification settings - Fork 0
Config Manager
The config manager uses TOML configuration files for your project and services.
from nautica import Config, ConfigBuilderNautica creates two config files at the root of your project automatically:
| File | ID | Description |
|---|---|---|
config.n3 |
nautica |
Core Nautica settings |
package-lock.n3 |
lock |
List of installed packages |
project.n3 |
projectdev |
Config for package development |
These are the only configs that live at the project root. All other configs
are created under config/.
Use dotted key paths to read values from a config:
Config("nautica")["nautica.debug"] # True/False
Config("nautica")["http.port"] # 8100
Config("nautica")["http.static.directory"] # /path/to/directoryYou can also call it directly:
Config("nautica")("http.port") # same as aboveBoth return None if the key doesn't exist
Config("nautica")["http.port"] = 9000Changes are saved automatically.
ConfigBuilder is used to define config keys with default values and
optional comments:
ConfigBuilder()
.add("key", default_value, comment="Optional comment")
.build()Keys use dot notation to define nested TOML tables:
ConfigBuilder()
.add("database.host", "127.0.0.1", comment="Database host")
.add("database.port", 5432)
.add("database.name", "mydb")
.build()Turns into:
[database]
host = "127.0.0.1" # Database host
port = 5432
name = "mydb"Services can register their own config files using Config.New(). This
should be done in onInstall():
from nautica import Service, Config, ConfigBuilder
class MyService(Service):
def onInstall(self):
Config.New("myservice",
ConfigBuilder()
.add("myservice.enabled", True, comment="Enable MyService")
.add("myservice.host", "127.0.0.1")
.add("myservice.port", 8200)
.build()
)This creates config/myservice.toml with the defined keys and values.
If the file already exists, missing keys are added without overwriting
existing values.
Use Config.Update() to add keys to an existing config without replacing it.
This is useful for built-in configs like nautica that multiple services
contribute to:
class MyService(Service):
def onInstall(self):
Config.Update("nautica",
ConfigBuilder()
.add("services.myservice", True, comment="Enable MyService")
.build()
)Use
Config.New()for your own config files, andConfig.Update()when adding keys to an existing one likenautica.
| Key | Default | Description |
|---|---|---|
nautica.debug |
true |
Enables debug mode and debug log output |
services.http |
false |
Enables the HTTP server |
services.shell |
true |
Enables the shell |
http.host |
127.0.0.1 |
Server host |
http.port |
8100 |
Server port |
http.realIPHeader |
"" |
Header to read real client IP from |
http.logRequests |
true |
Log even non-error requests |
http.websockets |
false |
Enable WebSocket support |
http.includeSchema |
true |
Include request schema in error responses |
http.docs |
false |
Expose OpenAPI Docs at /nautica:docs
|
http.static.enabled |
false |
Serve static files |
http.static.endpoint |
/static |
Static files endpoint |
http.static.directory |
/path/to/directory |
Static files directory |
http.cors.enabled |
false |
Enable CORS |
http.cors.origins |
["*"] |
Allowed origins |
http.cors.methods |
["*"] |
Allowed methods |
http.cors.headers |
["*"] |
Allowed headers |
http.cors.exposeHeaders |
[] |
List of exposed headers |
http.cors.credentials |
false |
Allow credentials |
shell.systemdMode |
false |
Disable console input for systemd |
shell.gui |
false |
Use TUI renderer |
shell.guiTheme |
frost |
TUI theme |
| Key | Default | Description |
|---|---|---|
name |
pwd |
Project name, a-z0-9._-
|
version |
1.0.0 |
Semantic Version |
dependsOn |
[] |
Dependency packages (names from registry) |
pyPackages |
[] |
PyPI dependencies (names from PyPI) |
- Home
- CLI Reference
- Service Registry
- Built-in Services
- Managers
- Requirement Validators