From: Greg Burri Date: Mon, 8 Mar 2021 12:19:21 +0000 (+0100) Subject: Merge branch 'master' of gburri.org:valheim_web into master X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=e9855a47ac1f9ebede015e89ec9cd1291c2876ea;hp=ec59a3ddbe97c216208c95995d6359ed1ebc30ca;p=valheim_web.git Merge branch 'master' of gburri.org:valheim_web into master --- diff --git a/backend/build.rs b/backend/build.rs index 8837cfc..0d6baba 100644 --- a/backend/build.rs +++ b/backend/build.rs @@ -26,6 +26,11 @@ fn main() { .expect("Unable to compile SASS file, install SASS, see https://sass-lang.com/") } + // Create static directory if it doesn't exist. + if !Path::new("static").exists() { + std::fs::create_dir("static"); + } + let output = if exists_in_path("sass.bat") { run_sass(Command::new("cmd").args(&["/C", "sass.bat"])) diff --git a/backend/src/main.rs b/backend/src/main.rs index 98ad670..d2607fd 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -30,7 +30,9 @@ pub struct Request { async fn main_page(/*key_shared: web::Data>,*/ query: Query) -> impl Responder { //let key = key_shared.lock().unwrap(); - let m = String::from("hello"); + let m = + if valheim_controller::is_valheim_running() { String::from("Valheim server is up and running") } else { String::from("Valheim server is down :(") }; + MainTemplate { sentence: m } } diff --git a/deploy.ps1 b/deploy.ps1 old mode 100644 new mode 100755 index f9b7dbf..5635894 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -1,3 +1,5 @@ +#!/usr/bin/env pwsh + if ($args.Count -lt 1) { $scriptName = [Environment]::GetCommandLineArgs()[1] Write-Output "Usage: $scriptName " @@ -7,7 +9,7 @@ if ($args.Count -lt 1) { git pull cargo build --release -systemctl --user stop valheim-web +systemctl --user stop valheim_web $destination=$args[0] @@ -15,15 +17,15 @@ if (!(Test-Path -Path $destination)) { New-Item -ItemType directory -Path $destination } -strip target/release/valheim-web # To reduce the executable size. -Copy-Item target/release/valheim-web -Destination $destination +strip target/release/valheim_web # To reduce the executable size. +Copy-Item target/release/valheim_web -Destination $destination -Copy-Item static -Destination $destination -Recurse -Force +Copy-Item backend/static -Destination $destination -Recurse -Force # Do not overwrite the configuration. if (!(Test-Path -Path $destination/conf.ron)) { - Copy-Item conf.ron -Destination $destination + Copy-Item backend/conf.ron -Destination $destination } -systemctl --user start valheim-web +systemctl --user start valheim_web diff --git a/doc/valheim_web.service b/doc/valheim_web.service new file mode 100644 index 0000000..37e070a --- /dev/null +++ b/doc/valheim_web.service @@ -0,0 +1,14 @@ +[Unit] +Description=valheim_web + +[Service] +WorkingDirectory=/var/www/valheim_web +ExecStart=/var/www/valheim_web/valheim_web +SyslogIdentifier=valheim_web +Restart=always +RestartSec=10 +KillSignal=SIGINT + +[Install] +WantedBy=default.target +