Compare commits

...

2 Commits

Author SHA1 Message Date
a9e4714a60 make it clear when you are in test setting
All checks were successful
CI/CD Pipeline / test (push) Successful in 5m18s
CI/CD Pipeline / deploy (push) Successful in 3m40s
2025-04-19 11:24:40 +02:00
a32d393836 add test systemd service file 2025-04-19 11:23:27 +02:00
5 changed files with 48 additions and 2 deletions

View File

@@ -1,5 +1,11 @@
# Stationslauf
## Demo-Instance
- [startest.it-results.at](https://startest.it-results.at)
- DB resets on every commit/deployment
- Default admin: "a"/"123"
## Marketing
- single-binary (+ db + .env)
- Teams werden automatisch (start)stationen zugewiesen

View File

@@ -30,7 +30,7 @@ use maud::{html, Markup};
use partials::page;
use serde::Deserialize;
use sqlx::SqlitePool;
use std::sync::Arc;
use std::{env, sync::Arc};
use tokio::net::TcpListener;
use tower_sessions::{cookie::time::Duration, Expiry, Session, SessionManagerLayer};
use tower_sessions_sqlx_store_chrono::SqliteStore;
@@ -41,6 +41,10 @@ pub(crate) mod models;
mod partials;
pub(crate) mod station;
pub(crate) fn test_version() -> bool {
env::var("TEST_VERSION").is_ok()
}
pub(crate) fn pl(amount: usize, single: &str, append: &str) -> String {
if amount == 1 {
single.into()

View File

@@ -16,6 +16,8 @@ async fn main() {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let db: SqlitePool = PoolOptions::new().connect(&database_url).await.unwrap();
// Test
// Axum
let port = env::var("PORT").expect("PORT must be set");
let listener = tokio::net::TcpListener::bind(&format!("0.0.0.0:{port}"))

View File

@@ -1,4 +1,5 @@
use maud::{DOCTYPE, Markup, html};
use crate::test_version;
use maud::{html, Markup, DOCTYPE};
use tower_sessions::Session;
pub(crate) async fn page(content: Markup, session: Session, leaflet: bool) -> Markup {
@@ -26,6 +27,22 @@ pub(crate) async fn page(content: Markup, session: Session, leaflet: bool) -> Ma
@if leaflet {
link rel="stylesheet" href="/leaflet.css";
}
@if test_version() {
style {
r#"
body {
margin: 0;
height: 100%;
background: repeating-linear-gradient(
45deg,
rgba(0, 0, 0, 0.3),
rgba(0, 0, 0, 0.3) 20px,
rgba(255, 255, 0, 0.3) 20px,
rgba(255, 255, 0, 0.3) 40px
);
}"#
}
}
}
body {
main class="container" {

17
startest.service Normal file
View File

@@ -0,0 +1,17 @@
[Unit]
Description=Stationslauf
[Service]
User=root
Group=root
WorkingDirectory=/home/startest
Environment="PORT=7002"
Environment="RUST_LOG=info"
Environment="TEST_VERSION=1"
Environment="DATABASE_URL=sqlite:///home/startest/db.sqlite"
ExecStart=/home/startest/star-test
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target