diff options
author | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-10 01:41:11 -0700 |
---|---|---|
committer | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-10 01:41:11 -0700 |
commit | b74bd67a4a25076812e86e7989a63b9540e68b25 (patch) | |
tree | 39824a177b8e3b4d25123392427442f6a3d4add1 | |
parent | 11155128178ff3d8ea803a70dd7749e594b247a9 (diff) | |
download | tilde.club-b74bd67a4a25076812e86e7989a63b9540e68b25.tar.gz tilde.club-b74bd67a4a25076812e86e7989a63b9540e68b25.zip |
attempt systemd deployment
-rwxr-xr-x | deploy.sh | 7 | ||||
-rwxr-xr-x | html/fruitvote/start.sh | 7 | ||||
-rw-r--r-- | html/public/fruitvote/GoPage.php | 13 | ||||
-rw-r--r-- | systemd/fruitvote.service | 10 |
4 files changed, 18 insertions, 19 deletions
@@ -1,10 +1,12 @@ -#!/bin/sh +#!/bin/bash set -e echo $SSH_KEY | base64 -d >> /tmp/key chmod -R 0600 /tmp/key +rsync -e "ssh -i /tmp/key -o StrictHostKeyChecking=no" -avz --delete ./systemd/ $RSYNC_DESTINATION/.config/systemd/user/ + cd dist for item in *; do echo "copying $item" @@ -20,4 +22,7 @@ done cd .. echo "finished copying to remote host..." +ssh -i /tmp/key -o StrictHostKeyChecking=no $(echo "${$RSYNC_DESTINATION%%:*}") "systemctl daemon reload --user && systemctl restart --user fruitvote" +echo "reloading fruitvote..." + rm /tmp/key diff --git a/html/fruitvote/start.sh b/html/fruitvote/start.sh deleted file mode 100755 index dd3036b..0000000 --- a/html/fruitvote/start.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -nice -n 19 /home/simponic/fruitvote/fruitvote \ - --users simponic,nginx \ - --socket-path /home/simponic/fruitvote/http.sock \ - & -# --database /home/simponic/fruitvote/db.sqlite \ diff --git a/html/public/fruitvote/GoPage.php b/html/public/fruitvote/GoPage.php index 27fc361..864c1f7 100644 --- a/html/public/fruitvote/GoPage.php +++ b/html/public/fruitvote/GoPage.php @@ -4,28 +4,19 @@ class GoPage { private $socket; private $template; - public function __construct($page, $socket = "/home/simponic/fruitvote/http.sock", $start_cmd="/home/simponic/fruitvote/start.sh", $template = "../template.html") { + public function __construct($page, $socket = "/home/simponic/fruitvote/http.sock", $template = "../template.html") { $this->page = $page; $this->socket = $socket; $this->template = $template; - // test if socket exists - if (!file_exists($socket)) { - // start the server - exec($start_cmd); - } - for ($i = 0; $i < 10; $i++) { if (file_exists($socket)) { break; } usleep(100_000); // wait 100ms } - - if (!file_exists($socket)) { - throw new Exception("Could not start server"); - } } + public function go() { $ch = curl_init(); $url = "http://localhost".$this->page; diff --git a/systemd/fruitvote.service b/systemd/fruitvote.service new file mode 100644 index 0000000..424aaf1 --- /dev/null +++ b/systemd/fruitvote.service @@ -0,0 +1,10 @@ +[Unit] +Description=fruitvote + +[Service] +Type=simple +ExecStart=/usr/bin/nice -n 19 /home/simponic/fruitvote/fruitvote --socket-path /home/simponic/fruitvote/http.sock --users nginx,simponic +Restart=always + +[Install] +WantedBy=default.target |