-
-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow embedding Lemmy, fix setup error #2618
Conversation
use std::{env, sync::Arc, thread, time::Duration}; | ||
use tracing_actix_web::TracingLogger; | ||
|
||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that this wasnt used at all, and we were already embedding migrations in db_schema crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird how rust didn't check the stuff in main, but I noticed that on my system too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its because the item is marked as public, so Rust will never mark it as unused as it might be used by another crate. Unfortunately there is no way to change this logic, so there are probably more public unused items across Lemmy codebase. The only tool I found to detect unused code in workspaces gave only false positives.
src/lib.rs
Outdated
const REQWEST_TIMEOUT: Duration = Duration::from_secs(10); | ||
|
||
/// Placing the main function in lib.rs allows other crates to import it and embed Lemmy | ||
pub async fn main2() -> Result<(), LemmyError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to something other than main2. Maybe like start
, entry
, run
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
use std::{env, sync::Arc, thread, time::Duration}; | ||
use tracing_actix_web::TracingLogger; | ||
|
||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird how rust didn't check the stuff in main, but I noticed that on my system too.
This moves the main.rs code into lib.rs, so that it can be included by other crates. I am using this in to test lemmyBB in LemmyNet/lemmyBB#70 so that no additional setup like bash scripts are needed. In the future I also plan to provide a production build variant of lemmyBB which embeds Lemmy, which will make installation easier (one less binary to install).
Additionally i noticed a bug during site setup, if none of the rate limit vars is set, diesel throws an error "There are no changes to save. This query cannot be built".