diff --git a/conf_files/pocs-supervisord.conf b/conf_files/pocs-supervisord.conf new file mode 100644 index 000000000..39f1930e8 --- /dev/null +++ b/conf_files/pocs-supervisord.conf @@ -0,0 +1,32 @@ +[program:pocs-config-server] +user=panoptes +directory=/home/panoptes +command=/home/panoptes/conda/envs/conda-pocs/bin/panoptes-config-server --host 0.0.0.0 --port 6563 run --config-file /home/panoptes/conf_files/pocs.yaml +stderr_logfile=/home/panoptes/logs/config-server.err.log +stdout_logfile=/home/panoptes/logs/config-server.out.log +autostart=true +autorestart=true +stopasgroup=true +startretries=3 + +[program:pocs-power-monitor] +user=panoptes +directory=/home/panoptes +command=/home/panoptes/conda/envs/conda-pocs/bin/uvicorn --host 0.0.0.0 --port 6564 panoptes.pocs.utils.service.power:app +stderr_logfile=/home/panoptes/logs/power-monitor.err.log +stdout_logfile=/home/panoptes/logs/power-monitor.out.log +autostart=true +autorestart=true +stopasgroup=true +startretries=3 + +[program:pocs-weather-report] +user=panoptes +directory=/home/panoptes +command=/usr/bin/zsh -c "/home/panoptes/conda/envs/conda-pocs/bin/pocs sensor monitor weather --read-frequency 90" +stderr_logfile=/home/panoptes/logs/weather-reader.err.log +stdout_logfile=/home/panoptes/logs/weather-reader.out.log +autostart=true +autorestart=true +stopasgroup=true +startretries=3 diff --git a/scripts/install/install-pocs.sh b/scripts/install/install-pocs.sh index 61bc138d2..5e07409a8 100644 --- a/scripts/install/install-pocs.sh +++ b/scripts/install/install-pocs.sh @@ -23,14 +23,9 @@ usage() { # # * Create # * Create the needed directory structure for POCS. -# * Install docker and tools on the host computer. # * Fetch the docker images needed to run. # * Source \${PANDIR}/env if it exists. # -# Docker Images: -# -# gcr.io/panoptes-exp/panoptes-pocs:develop -# # The regular install is for running units. # # The script has been tested with a fresh install of Ubuntu Server 20.10 @@ -71,7 +66,8 @@ USE_ZSH=false INSTALL_SERVICES=false DEFAULT_GROUPS="dialout,plugdev,input,sudo,docker" -ROUTER_IP="${ROUTER_IP:-192.168.8.1}" +# We use htpdate below so this just needs to be a public url w/ trusted time. +TIME_SERVER="${TIME_SERVER:-google.com}" CONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" CONDA_ENV_NAME=conda-pocs @@ -88,8 +84,6 @@ function which_branch() { } function get_time_settings() { - read -rp "What is the IP address of your router (default: ${ROUTER_IP})? " USER_NTP_SERVER - ROUTER_IP="${USER_NTP_SERVER:-$ROUTER_IP}" sudo dpkg-reconfigure tzdata } @@ -156,6 +150,7 @@ function system_deps() { make \ nano \ neovim \ + supervisor \ sshfs \ usbmount \ wget | sudo tee -a "${LOGFILE}" @@ -171,28 +166,6 @@ function system_deps() { } -function get_or_build_docker_images() { - echo "Pulling POCS docker images from Google Cloud Registry (GCR)." - - sudo docker pull "${DOCKER_IMAGE}:${CODE_BRANCH}" - - if [[ $HOST == *-control-box ]]; then - # Copy the docker-compose file - sudo docker run --rm -it \ - -v "${PANDIR}:/temp" \ - "${DOCKER_IMAGE}:${CODE_BRANCH}" \ - "cp /panoptes-pocs/docker/docker-compose.yaml /temp/docker-compose.yaml" - sudo chown "${PANUSER}:${PANUSER}" "${PANDIR}/docker-compose.yaml" - - # Copy the config file - sudo docker run --rm -it \ - -v "${PANDIR}:/temp" \ - "${DOCKER_IMAGE}:${CODE_BRANCH}" \ - "cp -rv /panoptes-pocs/conf_files/* /temp/conf_files/" - sudo chown -R "${PANUSER}:${PANUSER}" "${PANDIR}/conf_files/" - fi -} - function install_conda() { echo "Installing miniforge conda" @@ -233,10 +206,10 @@ dependencies: - streamz - uvicorn[standard] - pip: - - "git+https://github.com/panoptes/POCS@${CODE_BRANCH}#egg=panoptes-pocs[google,focuser,sensors]" - - docker-compose + - -e "${PANDIR}[google,focuser,sensors]" EOF + cd "${PANDIR}" "${HOME}/conda/envs/${CONDA_ENV_NAME}/bin/mamba" env update -p "${HOME}/conda/envs/${CONDA_ENV_NAME}" -f environment.yaml } @@ -262,49 +235,14 @@ function make_directories() { } function install_services() { - echo "Creating panoptes-config-server service." - - sudo bash -c 'cat > /etc/systemd/system/panoptes-config-server.service' < /etc/systemd/system/panoptes-power-server.service' <>"${LOGFILE}" + echo "Starting POCS install at $(date)" >>"${LOGFILE}" name_me @@ -401,33 +330,25 @@ function do_install() { echo "PANDIR: ${PANDIR}" echo "HOST: ${HOST}" echo "Logfile: ${LOGFILE}" - # echo "DOCKER_IMAGE: ${DOCKER_IMAGE}" echo "CODE_BRANCH: ${CODE_BRANCH}" - # Make sure the time setting is correct on RPi. - if [ "$(uname -m)" = "aarch64" ]; then - echo "ROUTER_IP: ${ROUTER_IP}" - fix_time - fi - + fix_time system_deps if [[ "${USE_ZSH}" == true ]]; then install_zsh fi - install_conda - get_pocs_repo + install_conda + make_directories if [[ "${INSTALL_SERVICES}" == true ]]; then install_services fi - # get_or_build_docker_images - echo "Please reboot your machine before using POCS." read -p "Reboot now? [y/N]: " -r