From 02cd33c97bbeb18521df544cdd868236537eaa73 Mon Sep 17 00:00:00 2001
From: Vitor Trovisco <vmt25@cam.ac.uk>
Date: Wed, 3 Aug 2022 08:39:23 +0000
Subject: [PATCH] Add new  - canto-test-docker-initd (for setting server mode
 for a testing branch at /data/export/canto-space

---
 canto-test-docker-initd | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 canto-test-docker-initd

diff --git a/canto-test-docker-initd b/canto-test-docker-initd
new file mode 100644
index 0000000..28a7a98
--- /dev/null
+++ b/canto-test-docker-initd
@@ -0,0 +1,38 @@
+#! /bin/sh
+# /etc/init.d/canto
+
+# Installation instructions: https://github.com/pombase/canto/blob/master/etc/canto-init.d.md
+
+action=$1
+port=$2
+
+WORKERS=5
+CANTO_SPACE='/data/export/canto-space/testing'
+
+PID_PATH=import_export/canto-test.pid
+
+# Carry out specific functions when asked to by the system
+case "$action" in
+  start)
+
+    echo "Starting Canto with $WORKERS workers"
+
+    (date; cd $CANTO_SPACE; canto/script/canto_docker --non-interactive --use-container-name start_server --pid-file=/$PID_PATH --port $port -- script/canto_start --workers $WORKERS --keepalive-timeout 5 -s Starman --preload) >> canto-test.log 2>&1 &
+    ;;
+  stop)
+    pid=`/bin/cat $CANTO_SPACE/$PID_PATH`
+    echo stopping $pid
+    (cd $CANTO_SPACE; docker exec canto kill -TERM $pid)
+    ;;
+  restart)
+    pid=`/bin/cat $CANTO_SPACE/$PID_PATH`
+    echo restarting $pid
+    (cd $CANTO_SPACE; docker exec canto kill -HUP $pid)
+    ;;
+  *)
+    echo "Usage: $0 {start|restart|stop}"
+    exit 1
+    ;;
+esac
+
+exit 0
-- 
GitLab