systemdify this

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2021-01-02 18:11:18 -05:00
parent d63f393193
commit 951542ccf2
5 changed files with 31 additions and 24 deletions

View File

@ -16,24 +16,3 @@ jobs:
with:
name: xe
- run: nix-build --no-out-link
- name: Log into GitHub Container Registry
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u Xe --password-stdin
- name: Docker push
if: github.ref == 'refs/heads/main'
run: |
nix-build ./docker.nix
docker load -i result
docker tag xena/christinewebsite:latest ghcr.io/xe/site:$GITHUB_SHA
docker push ghcr.io/xe/site
- name: deploy
if: github.ref == 'refs/heads/main'
run: ./scripts/release.sh
env:
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
MI_TOKEN: ${{ secrets.MI_TOKEN }}
PATREON_ACCESS_TOKEN: ${{ secrets.PATREON_ACCESS_TOKEN }}
PATREON_CLIENT_ID: ${{ secrets.PATREON_CLIENT_ID }}
PATREON_CLIENT_SECRET: ${{ secrets.PATREON_CLIENT_SECRET }}
PATREON_REFRESH_TOKEN: ${{ secrets.PATREON_REFRESH_TOKEN }}
DHALL_PRELUDE: https://raw.githubusercontent.com/dhall-lang/dhall-lang/v17.0.0/Prelude/package.dhall

7
Cargo.lock generated
View File

@ -1874,6 +1874,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sdnotify"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71ce7eac2075a4562fbcbad544cd55d72ebc760e0a5594a7c8829cf2b4b42a7a"
[[package]]
name = "security-framework"
version = "2.0.0"
@ -2783,6 +2789,7 @@ dependencies = [
"rand 0.7.3",
"reqwest",
"ructe",
"sdnotify",
"serde",
"serde_dhall",
"serde_json",

View File

@ -21,6 +21,7 @@ log = "0.4"
mime = "0.3.0"
prometheus = { version = "0.10", default-features = false, features = ["process"] }
rand = "0"
sdnotify = { version = "0.1", default-features = false }
serde_dhall = "0.8.0"
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.8"

View File

@ -4,7 +4,10 @@ use std::process::Command;
fn main() -> Result<()> {
Ructe::from_env()?.compile_templates("templates")?;
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GITHUB_SHA={}", git_hash);
Ok(())

View File

@ -1,3 +1,6 @@
#[macro_use]
extern crate tracing;
use color_eyre::eyre::Result;
use hyper::{header::CONTENT_TYPE, Body, Response};
use prometheus::{Encoder, TextEncoder};
@ -24,7 +27,7 @@ async fn main() -> Result<()> {
color_eyre::install()?;
let _ = kankyo::init();
tracing_subscriber::fmt::init();
log::info!("starting up commit {}", env!("GITHUB_SHA"));
info!("starting up commit {}", env!("GITHUB_SHA"));
let state = Arc::new(
app::init(
@ -161,7 +164,21 @@ async fn main() -> Result<()> {
.with(warp::log(APPLICATION_NAME))
.recover(handlers::rejection);
warp::serve(site).run(([0, 0, 0, 0], 3030)).await;
if let Ok(ref mut n) = sdnotify::SdNotify::from_env() {
let _ = n
.notify_ready()
.map_err(|why| error!("can't signal readiness to systemd: {}", why));
}
warp::serve(site)
.run((
[0, 0, 0, 0],
std::env::var("PORT")
.unwrap_or("3030".into())
.parse::<u16>()
.unwrap(),
))
.await;
Ok(())
}