···11-LUMINARY_PROJECT_DIRECTORY=/opt/stacks # Directory where Luminary will look for projects.11+LUMINARY_PROJECT_DIRECTORY=/opt/stacks # Directory where Luminary will look for projects.
22+LUMINARY_ADDRESS=0.0.0.0:9000 # Address and port that the Luminary Node will listen on.
33+RUST_LOG=info # Set the log level for the Luminary Node
+1-3
packages/node/src/api/mod.rs
···22222323/// Sets up the app router and all dependencies.
2424#[wrap_err("Crashed while setting up")]
2525-pub async fn setup(pool: SqlitePool, logs: BroadcastLayer) -> Result<Router> {
2626- let engine = LuminaryEngine::setup().await?;
2727-2525+pub async fn setup(engine: LuminaryEngine, pool: SqlitePool, logs: BroadcastLayer) -> Result<Router> {
2826 // Set up the affix state with all dependencies
2927 let affix = affix_state::inject(LuminaryAuthentication::new(pool.clone()))
3028 .inject(engine)
+17
packages/node/src/configuration.rs
···11+use serde::Deserialize;
22+33+/// A struct containing Luminary configuration, to be loaded from environment variables.
44+#[derive(Deserialize, Debug)]
55+pub struct LuminaryConfiguration {
66+ /// The directory where Luminary will look to find projects.
77+ pub project_directory: String,
88+99+ /// The address and port that the Luminary Node will listen on.
1010+ #[serde(default = "default_address")]
1111+ pub address: String,
1212+}
1313+1414+// Provides a default address for the Luminary Node.
1515+fn default_address() -> String {
1616+ return "0.0.0.0:9000".to_string();
1717+}
-7
packages/node/src/core/configuration.rs
···11-use serde::Deserialize;
22-33-/// A struct containing Luminary configuration, to be loaded from environment variables.
44-#[derive(Deserialize, Debug)]
55-pub struct LuminaryConfiguration {
66- pub project_directory: String,
77-}
+5-3
packages/node/src/core/engine.rs
···1414 sync::{Mutex, RwLock, broadcast},
1515};
16161717-use crate::core::{LuminaryStateList, ProjectLogChannel, configuration::LuminaryConfiguration};
1717+use crate::{
1818+ configuration::LuminaryConfiguration,
1919+ core::{LuminaryStateList, ProjectLogChannel},
2020+};
18211922/// The core engine of the Luminary application, containing shared state and configuration.
2023#[derive(Debug, Clone)]
···3841impl LuminaryEngine {
3942 /// Initializes a new instance of the Engine struct, loading configuration from environment variables and connecting to the Docker engine.
4043 #[wrap_err("Failed to create LuminaryEngine")]
4141- pub async fn setup() -> Result<Self> {
4444+ pub async fn setup(configuration: Arc<LuminaryConfiguration>) -> Result<Self> {
4245 let docker = Docker::connect_with_defaults().wrap_err("Failed to connect to docker engine.")?;
4343- let configuration = Arc::new(envy::prefixed("LUMINARY_").from_env::<LuminaryConfiguration>()?);
44464547 let instance = Self {
4648 state: Arc::new(RwLock::new(LuminaryStateList::new())),
···11//! The main entry point for the Luminary Node, which serves as the backend for the Luminary Panel.
2233+use std::sync::Arc;
44+35use eyre::{Context, Result};
46use log::debug;
57use salvo::prelude::*;
···810 EnvFilter, Layer, filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt,
911};
10121313+use crate::{configuration::LuminaryConfiguration, core::LuminaryEngine};
1414+1115const DATABASE: &str = "luminary.db";
12161317mod api;
1818+mod configuration;
1419mod core;
1520mod logging;
1621mod util;
···3237 .with(fmt_layer)
3338 .init();
34394040+ // Load configuration
4141+ #[cfg(debug_assertions)]
4242+ let configuration = Arc::new(envy::prefixed("LUMINARY_").from_env::<LuminaryConfiguration>()?);
4343+3544 // Set up the app and dependencies
3636- let listener = TcpListener::new("0.0.0.0:9000").bind().await;
3737- let router = api::setup(setup_database().await?, broadcast_layer).await?;
4545+ let listener = TcpListener::new(configuration.address.clone()).bind().await;
4646+ let engine = LuminaryEngine::setup(configuration).await?;
4747+ let pool = setup_database().await?;
4848+4949+ let router = api::setup(engine, pool, broadcast_layer).await?;
38503951 // Log router structure for debugging
4052 debug!("Router structure: {router:?}");