From: Greg Burri Date: Mon, 8 Mar 2021 08:32:35 +0000 (+0100) Subject: Add a message to know if the server is running or not. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=e329e71ea8768a41734a5df03102825fdb88b011;p=valheim_web.git Add a message to know if the server is running or not. --- 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 +