#Tauri shutdown right away
92 messages · Page 1 of 1 (latest)
have you tried npm run tauri build
sadly.. same issue
This has occurred since you added the settings.
pub fn create_db_pool() -> DbPool {
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(&database_url);
Pool::builder()
.build(manager)
.expect("Failed to create pool.")
} ```
dotenv::dotenv().ok();
// simple_logger를 초기화합니다. (오류 로그를 더 잘 볼 수 있게 합니다)
simple_logger::init().unwrap();
tauri::Builder::default()
.manage(create_db_pool()) // DB 풀을 애플리케이션 상태로 관리합니다.
.invoke_handler(tauri::generate_handler![
load_json_data,
update_image_data,
get_real_image, // 필요한 모든 핸들러를 등록합니다.
])
.setup(|app| {
#[cfg(debug_assertions)] // 개발 중일 때만 개발자 도구를 엽니다.
{
if let Some(window) = app.get_window("main") {
window.open_devtools();
}
}
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
} ```
try running it through the terminal instead of double clicking it
also try moving the .env file to the same directory of the debug/
rename the env file to .env
same issue..
There's nothing special about the composition of the code..
I'm not sure but it might be a panic or an expectation that's crashing it then it's caches so it works after
Do you use the FS API in rust or the front-end side by any random chance?
can you show me all of the code of that file
np but can you take a screenshot cuz I'm on my phone
ye please
The whole thing is too much, so I only attach commands.rs and main.rs . Is there a problem here?
I'll sort it
commands.rs
field and dependencies, and dbPool
fn load_json_data
fn update_image_data
fn get_real_img
fn decode_base64_image_data
fn get_home_directory
The last corrections are fn 'get_real_img' and dbPool
main.rs
commands.rs - fn load_image_as_base64
On Windows, running with start will create a new terminal. You want to bind your app to the current terminal so you see the output. To do that, you run the app directly without start like so: tauri.exe.
Thank you, I'll give it a try.
same issue..
It's strange that you're not getting output. What command did you use to compile your app?
Can you also share your tauri.conf.json file? Mainly interested in anything inside the windows array.
I tried 'npm run tauri build' and 'tauri build'
To be precise, this has happened since we added dataPool.
use diesel::r2d2::{self, ConnectionManager, Pool};
npm run tauri dev will give you output on Windows. npm run tauri build will suppress the output to prevent a terminal showing with the app.
It's probably a panic somewhere from unwrap() but it doesn't hurt to be sure where it's happening by getting output.
npm run tauri dev is the same phenomenon
It's shut down right away, and it only takes a few times to execute
There should be an error shown in the console if it's closing because of a panic.
Can you add some println! in various places to see where it gets up to?
Do you have your code available online somewhere?
It doesn't run at all, so even println!, which should be run first, doesn't run.
no..
No error logs appear at all.
So even println! at the very beginning of main() doesn't work? Can you comment out line 2 of main.rs where it says "windows_subsystem = "windows"? That's what suppresses the println! which means your app is always building without debug_assertions.
//#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] << now my setting
on main.rs
There is no error log when it is not running..
dumb idea: try moving it to a dir with no special charactors
If moving directories doesn't work, can you try println! between each part of the main()? The goal is to find out where the code stops, even if it's not producing an error.
// .env 파일에서 환경 변수들을 불러옵니다.
dotenv::dotenv().ok();
// DATABASE_URL 환경 변수에서 데이터베이스 연결 정보를 불러옵니다.
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let manager = ConnectionManager::<PgConnection>::new(database_url);
let pool = r2d2::Pool::builder()
.build(manager)
.expect("Failed to create pool.");
// 연결을 시도하고, 실패할 경우 재시도합니다.
loop {
match pool.get() {
Ok(_) => {
println!("Successfully connected to the database.");
break; // 연결 성공 시 루프를 빠져나온 후, 풀을 반환
},
Err(e) => {
println!("Failed to connect to database: {}, will retry in 5 seconds", e);
thread::sleep(Duration::from_secs(5)); // 5초 후에 다시 시도
}
}
}
pool
} ```
This code is a code that was modified to reconnect because it was suspected that the execution was shut down due to a db connection.
When running normally, it runs up to println! ("Successfully connected to the database") of the db connection, but if not, it runs up to println! ("Starting application...") on main.rs and shuts down.
That sounds like it would be failing on the .expect from Pool::builder(). I don't see any other code that would cause a complete exit of the program.
If you run it from the terminal with tauri.exe, you should get that last line of output. It's probably closing before it can print.
oh right
Is there any element here that might cause tauri.exe to shut down?
There seems to be an error in this part
There are 2 .expect() inside the create_db_pool function which might cause it. Beyond that, this would be an exercise in debugging the r2d2 library.