Files
hla_framework_bd/bin/start_service.sh
T
Benjamin Labrecque fa7d8a08da
Deploy / deploy (push) Successful in 1s
fix: uv in startup script
2026-07-24 16:01:22 +02:00

46 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
SVC_NAME=$1
set --
# TODO: remove?
# PSI_FACILITY=SLS
SERVICES_DIR=/sls/bd/hla/${AGEBD_ENV}/services
SVC_NAME_LOWER=${SVC_NAME,,}
SVC_NAME_LOWER_UNDERSCORES="${SVC_NAME_LOWER//-/_}"
SVC_DIR=${SERVICES_DIR}/${SVC_NAME_LOWER}
# gfa_12_epics.sh died on the 16.04.2026 due to required AFS write access
#. /etc/profile.d/gfa_12_epics.sh
#. /sls/bd/exchange/BeamData/user/felix/workarounds/epicsRHEL8.rc # temporary fix
. /etc/profile.d/cas_12_epics.sh
# TODO: only for dev
export EPICS_CA_ADDR_LIST='sls-cagw.psi.ch:5062 129.129.146.88'
# activate conda environment
. /opt/gfa/python-3.10/latest/bin/activate
# TODO: building the .venv should be done in CICD (only when uv.lock changes)
pip install uv
# to run `uv ...`
PATH="${HOME}/.local/bin:${PATH}"
export UV_CACHE_DIR="/sls/bd/hla/.cache/uv"
export UV_LINK_MODE="copy"
APP_DIR=${SVC_DIR}/current/app
echo "App dir: ${APP_DIR}"
uv venv --project "${APP_DIR}" --allow-existing
# install custom python packages from pyproject.toml / uv.lock
uv sync --frozen --project ${APP_DIR}
# activate .venv, this works in conjunction with the conda environment
source ${APP_DIR}/.venv/bin/activate
# TODO: use `exec python3 ...` here?
python -u -B -m agebd_${SVC_NAME_LOWER_UNDERSCORES}.main
# TODO: remove: cicd test 10