This commit is contained in:
parent
b40c7a0262
commit
8a52d12891
|
@ -32,7 +32,7 @@ proxy:
|
|||
# the last command to be long-running (e.g. an application server). When the
|
||||
# last command exits, LiteFS is shut down.
|
||||
exec:
|
||||
- cmd: "DATABASE_PATH=/litefs/db /app/gabrielsimmerdotcom --bind 0.0.0.0:8081"
|
||||
- cmd: "/app/gabrielsimmerdotcom --bind 0.0.0.0:8081 --database-path=/litefs/db"
|
||||
|
||||
# The lease section specifies how the cluster will be managed. We're using the
|
||||
# "consul" lease type so that our application can dynamically change the primary.
|
||||
|
|
|
@ -32,6 +32,8 @@ use crate::cache::{Cache, init_cache};
|
|||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
#[arg(short, long, default_value_t=("gs.db").to_string())]
|
||||
database_path: String,
|
||||
#[arg(short, long, default_value_t=("0.0.0.0:3000").to_string())]
|
||||
bind: String,
|
||||
}
|
||||
|
@ -78,14 +80,15 @@ impl Render for Project {
|
|||
#[tokio::main]
|
||||
async fn main() -> Result<(), sqlx::Error> {
|
||||
let args = Cli::parse();
|
||||
let path = env::var("DATABASE_PATH").unwrap_or("gs.db".to_owned());
|
||||
let opts = SqliteConnectOptions::from_str(&path)?
|
||||
|
||||
let opts = SqliteConnectOptions::from_str(&args.database_path)?
|
||||
.journal_mode(SqliteJournalMode::Wal)
|
||||
.create_if_missing(true);
|
||||
|
||||
let pool = SqlitePoolOptions::new().connect_with(opts).await?;
|
||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||
|
||||
env::set_var("DATABASE_PATH", &args.database_path);
|
||||
let state = AppState { cache: init_cache().await };
|
||||
|
||||
let app = Router::new()
|
||||
|
|
Loading…
Reference in a new issue