diff --git a/toolforge/build.sh b/toolforge/build.sh new file mode 100755 index 0000000..d8c9894 --- /dev/null +++ b/toolforge/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +toolforge jobs run build --command "bash -c 'source ~/.profile && cd ~/ircservserv && cargo build --release'" --image python3.11 --mem 2G --cpu 3 --wait 3600 --filelog-stdout logs/build-out.log --filelog-stderr logs/build-err.log diff --git a/toolforge/deployment.yaml b/toolforge/deployment.yaml deleted file mode 100644 index 39e39e1..0000000 --- a/toolforge/deployment.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -# Run ircservserv on kubernetes -# Adapted from stashbot's deployment file -apiVersion: apps/v1 -kind: Deployment -metadata: - name: ircservserv - namespace: tool-ircservserv - labels: - name: ircservserv - toolforge: tool -spec: - replicas: 1 - selector: - matchLabels: - name: ircservserv - toolforge: tool - template: - metadata: - labels: - name: ircservserv - # Mount NFS - toolforge: tool - spec: - containers: - - name: ircservserv - image: docker-registry.tools.wmflabs.org/toolforge-buster-sssd:latest - command: [ "/data/project/ircservserv/ircservserv-config/toolforge/manage.sh", "run" ] - workingDir: /data/project/ircservserv - env: - - name: HOME - value: /data/project/ircservserv - imagePullPolicy: Always diff --git a/toolforge/jobs.yaml b/toolforge/jobs.yaml new file mode 100644 index 0000000..3ec1ebb --- /dev/null +++ b/toolforge/jobs.yaml @@ -0,0 +1,12 @@ +- command: logrotate -v $TOOL_DATA_DIR/logrotate.conf --state $TOOL_DATA_DIR/.logrotate.state + emails: onfailure + filelog-stderr: logs/logrotate-err.log + filelog-stdout: logs/logrotate-out.log + image: mariadb + name: logrotate + schedule: '@daily' +- command: ./ircservserv/target/release/ircservserv + continuous: true + emails: onfailure + image: bookworm + name: ircservserv diff --git a/toolforge/manage.sh b/toolforge/manage.sh deleted file mode 100755 index 12beed9..0000000 --- a/toolforge/manage.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash -# Management script for ircservserv kubernetes processes -# Adapted from stashbot scripts - -set -e - -DEPLOYMENT=ircservserv -POD_NAME=ircservserv - -APP_DIR=/data/project/ircservserv/ircservserv -CONFIG_DIR=/data/project/ircservserv/ircservserv-config -DEPLOYMENT_FILE=${CONFIG_DIR}/toolforge/deployment.yaml - -KUBECTL=/usr/bin/kubectl - -_get_pod() { - $KUBECTL get pods \ - --output=jsonpath={.items..metadata.name} \ - --selector=name=${POD_NAME} -} - -case "$1" in - start) - echo "Starting ircservserv k8s deployment..." - $KUBECTL create --validate=true -f ${DEPLOYMENT_FILE} - ;; - run) - date +%Y-%m-%dT%H:%M:%S - echo "Running ircservserv..." - cd ${CONFIG_DIR} - ${APP_DIR}/target/release/ircservserv - ;; - stop) - echo "Stopping the Kubernetes deployment..." - $KUBECTL delete deployment ${DEPLOYMENT} - # FIXME: wait for the pods to stop - ;; - restart) - echo "Restarting the running pod..." - exec $KUBECTL delete pod $(_get_pod) - ;; - status) - echo "Active pods:" - exec $KUBECTL get pods -l name=${POD_NAME} - ;; - tail) - exec $KUBECTL logs -f $(_get_pod) - ;; - attach) - echo "Attaching to pod..." - exec $KUBECTL exec -i -t $(_get_pod) -- /bin/bash - ;; - compile) - echo "Compiling ircservserv on the grid..." - cd ${APP_DIR} - time jsub -N build -mem 2G -sync y -cwd cargo build --release - ;; - *) - echo "Usage: $0 {start|stop|restart|status|tail|attach|compile}" - exit 1 - ;; -esac - -exit 0 -