almost prod product
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -368,7 +368,9 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
@@ -2454,6 +2456,7 @@ name = "rust_leptos"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
"console_error_panic_hook",
|
||||
"jsonwebtoken",
|
||||
"leptos",
|
||||
|
||||
@@ -35,6 +35,7 @@ tracing-subscriber = { version = "0.3", features = ["fmt"] }
|
||||
tracing-wasm = { version = "0.2", optional = true }
|
||||
|
||||
wasm-bindgen = "0.2.93"
|
||||
chrono = "0.4.38"
|
||||
|
||||
[features]
|
||||
default = ["ssr", "hydrate"]
|
||||
@@ -119,7 +120,7 @@ lib-features = ["hydrate"]
|
||||
# Optional. Defaults to false.
|
||||
lib-default-features = false
|
||||
|
||||
bin-target-triple = "aarch64-unknown-linux-gnu"
|
||||
#bin-target-triple = "aarch64-unknown-linux-gnu"
|
||||
|
||||
tailwind-input-file = "input.css"
|
||||
tailwind-config-file = "tailwind.config.js"
|
||||
|
||||
9
Makefile
9
Makefile
@@ -1,5 +1,8 @@
|
||||
deploy:
|
||||
npx tailwindcss -i ./input.css -o ./style/output.css --minify
|
||||
cargo build --release --target=aarch64-unknown-linux-gnu -vv
|
||||
scp target/release/rust_leptos raspiwork:/var/www/rust_leptos/
|
||||
cargo leptos build
|
||||
#cargo leptos build --release
|
||||
ssh raspiwork "sudo systemctl stop rust_leptos.service"
|
||||
scp target/aarch64-unknown-linux-gnu/debug/rust_leptos raspiwork:/var/www/rust_leptos/rust_leptos
|
||||
#scp target/aarch64-unknown-linux-gnu/debug/rust_leptos raspiwork:/var/www/rust_leptos/rust_leptos
|
||||
scp -r target/site raspiwork:/var/www/rust_leptos/site/
|
||||
ssh raspiwork "sudo systemctl start rust_leptos.service"
|
||||
|
||||
15
README.md
15
README.md
@@ -3,6 +3,21 @@ source : https://github.com/Oishh/leptos-axum-tailwind-start
|
||||
wasm-pack build --target=web --debug --no-default-features --features=hydrate
|
||||
cargo run --no-default-features --features=ssr
|
||||
|
||||
example of systemd config
|
||||
```
|
||||
[Unit]
|
||||
Description=Running rust script
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=/home/pi/Scripts/rust_mosquitto/target/release/.env
|
||||
ExecStart=/home/pi/Scripts/rust_mosquitto/target/release/rust_mosquitto
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
# dev
|
||||
source .env
|
||||
cargo sqlx migrate run
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS donnees (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
service varchar(12) NOT NULL,
|
||||
capteur varchar(12) NOT NULL,
|
||||
type varchar(12) NOT NULL,
|
||||
donnee varchar(12) NOT NULL,
|
||||
date_donnee datetime NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
CREATE INDEX grafana_index ON donnees(date_donnee, capteur, type);
|
||||
@@ -2,7 +2,6 @@ static DB: std::sync::OnceLock<sqlx::MySqlPool> = std::sync::OnceLock::new();
|
||||
|
||||
async fn create_pool() -> sqlx::MySqlPool {
|
||||
let database_url = std::env::var("DATABASE_URL").expect("no database url specify");
|
||||
dbg!(&database_url);
|
||||
let pool = sqlx::mysql::MySqlPoolOptions::new()
|
||||
.max_connections(4)
|
||||
.connect(database_url.as_str())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(feature = "ssr")]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
rust_leptos::setup::init_app(Some("Cargo.toml")).await;
|
||||
rust_leptos::setup::init_app(None).await;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
|
||||
@@ -61,11 +61,12 @@ impl Value {
|
||||
};
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO donnees(service, capteur, type, donnee, date_donnee) VALUES (?, ?, ?, ?, NOW())",
|
||||
"INSERT INTO donnees(service, capteur, type, donnee, date_donnee) VALUES (?, ?, ?, ?, ?)",
|
||||
option.service,
|
||||
option.device,
|
||||
option.r_type,
|
||||
value,
|
||||
chrono::Local::now().naive_local(),
|
||||
)
|
||||
.execute(crate::database::get_db())
|
||||
.await
|
||||
|
||||
@@ -8,6 +8,7 @@ pub fn Links() -> impl IntoView {
|
||||
<ul class="flex gap-5 mt-5 justify-center">
|
||||
<Link link="aa".to_string() name="Mon Lien".to_string() />
|
||||
<Link link="aa".to_string() name="mon lien 2".to_string() />
|
||||
<Link link="aa".to_string() name="mon lien 3".to_string() />
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@ use leptos_axum::{generate_route_list, LeptosRoutes};
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
/// # Panics
|
||||
///
|
||||
/// Will panic if anything is badly setup from database, or web server
|
||||
pub async fn init_app(configuration_path: Option<&str>) {
|
||||
tracing_subscriber::fmt()
|
||||
.with_level(true)
|
||||
@@ -24,7 +21,7 @@ pub async fn init_app(configuration_path: Option<&str>) {
|
||||
let leptos_options = conf.leptos_options;
|
||||
let serve_dir = tower_http::services::ServeDir::new(&leptos_options.site_root)
|
||||
.append_index_html_on_directories(false);
|
||||
|
||||
logging::log!("listening on http://{}", &addr);
|
||||
let app = axum::Router::new()
|
||||
.leptos_routes(&leptos_options, routes, || view! { <App/> })
|
||||
.fallback_service(serve_dir)
|
||||
|
||||
Reference in New Issue
Block a user