aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2021-01-02 18:11:18 -0500
committerChristine Dodrill <me@christine.website>2021-01-02 18:11:27 -0500
commit951542ccf26c1089c24100f0ff1208981979c841 (patch)
treeeed9186391e8e4f7317a15074ea9e19552aa9b5e
parentd63f39319397cc8d804f7642b93dd5c23636b285 (diff)
downloadxesite-951542ccf26c1089c24100f0ff1208981979c841.tar.xz
xesite-951542ccf26c1089c24100f0ff1208981979c841.zip
systemdify this
Signed-off-by: Christine Dodrill <me@christine.website>
-rw-r--r--.github/workflows/nix.yml21
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--src/build.rs5
-rw-r--r--src/main.rs21
5 files changed, 31 insertions, 24 deletions
diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml
index aa9bb0d..cbfb540 100644
--- a/.github/workflows/nix.yml
+++ b/.github/workflows/nix.yml
@@ -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
diff --git a/Cargo.lock b/Cargo.lock
index 3b31adb..3eee214 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1875,6 +1875,12 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2783,6 +2789,7 @@ dependencies = [
"rand 0.7.3",
"reqwest",
"ructe",
+ "sdnotify",
"serde",
"serde_dhall",
"serde_json",
diff --git a/Cargo.toml b/Cargo.toml
index 7bf70a7..48b0eee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/src/build.rs b/src/build.rs
index 3b73241..0d8d5a5 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -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(())
diff --git a/src/main.rs b/src/main.rs
index 0baaeef..0d3b1ca 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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(())
}