diff options
| author | Ellie Huxtable <e@elm.sh> | 2021-04-14 18:40:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-14 17:40:50 +0000 |
| commit | f6de558070c4ed4dbecf4bbbf4693e396a5577dc (patch) | |
| tree | 174dcd5f1341e2845ea30cff6521e36170e8a0d5 /src/remote/server.rs | |
| parent | Bump reqwest from 0.11.2 to 0.11.3 (#33) (diff) | |
| download | atuin-f6de558070c4ed4dbecf4bbbf4693e396a5577dc.zip | |
Optimise docker (#34)
* Smaller dockerfile, better error handling
* Add config dir
Diffstat (limited to 'src/remote/server.rs')
| -rw-r--r-- | src/remote/server.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/remote/server.rs b/src/remote/server.rs index de58397d..ee481ca4 100644 --- a/src/remote/server.rs +++ b/src/remote/server.rs @@ -1,5 +1,3 @@ -use rocket::config::{Config, Environment, LoggingLevel, Value}; - use std::collections::HashMap; use crate::remote::database::establish_connection; @@ -7,6 +5,9 @@ use crate::settings::Settings; use super::database::AtuinDbConn; +use eyre::Result; +use rocket::config::{Config, Environment, LoggingLevel, Value}; + // a bunch of these imports are generated by macros, it's easier to wildcard #[allow(clippy::clippy::wildcard_imports)] use super::views::*; @@ -16,7 +17,7 @@ use super::auth::*; embed_migrations!("migrations"); -pub fn launch(settings: &Settings, host: String, port: u16) { +pub fn launch(settings: &Settings, host: String, port: u16) -> Result<()> { let settings: Settings = settings.clone(); // clone so rocket can manage it let mut database_config = HashMap::new(); @@ -25,7 +26,8 @@ pub fn launch(settings: &Settings, host: String, port: u16) { database_config.insert("url", Value::from(settings.server.db_uri.clone())); databases.insert("atuin", Value::from(database_config)); - let connection = establish_connection(&settings); + let connection = establish_connection(&settings)?; + embedded_migrations::run(&connection).expect("failed to run migrations"); let config = Config::build(Environment::Production) @@ -54,4 +56,6 @@ pub fn launch(settings: &Settings, host: String, port: u16) { .attach(AtuinDbConn::fairing()) .register(catchers![internal_error, bad_request]) .launch(); + + Ok(()) } |
