diff --git a/compose/.env b/compose/.env new file mode 100644 index 0000000..cc98b32 --- /dev/null +++ b/compose/.env @@ -0,0 +1,5 @@ +KAMERA_CORE_IMAGE=kitware/kamera:core +KAMERA_KAMERAD_IMAGE=kitware/kamera:kamerad +KAMERA_VIAME_IMAGE=kitware/kamera:viame +KAMERA_POSTPROC_IMAGE=kitware/kamera:postproc +KAMERA_GUI_IMAGE=kitware/kamera:gui diff --git a/compose/cam_ir.yml b/compose/cam_ir.yml index 83ce7f1..72629af 100644 --- a/compose/cam_ir.yml +++ b/compose/cam_ir.yml @@ -1,10 +1,9 @@ --- ## Auxiliary node to attach to master -version: '3.7' services: cam_ir: container_name: "cam-ir-${CAM_FOV}" - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/compose/cam_param_monitor.yml b/compose/cam_param_monitor.yml index ddb60f5..89763a5 100644 --- a/compose/cam_param_monitor.yml +++ b/compose/cam_param_monitor.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: cam_param_monitor: container_name: cam_param_monitor - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/compose/cam_rgb.yml b/compose/cam_rgb.yml index 83f9a69..6d19903 100644 --- a/compose/cam_rgb.yml +++ b/compose/cam_rgb.yml @@ -1,11 +1,10 @@ --- ## Auxiliary node to attach to master -version: '3.7' services: ## =========================== headless nodes ============================= cam_rgb: container_name: "cam-rgb-${CAM_FOV}" - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/compose/cam_uv.yml b/compose/cam_uv.yml index 18732cc..fbd3d59 100644 --- a/compose/cam_uv.yml +++ b/compose/cam_uv.yml @@ -1,11 +1,10 @@ --- ## Auxiliary node to attach to master -version: '3.7' services: ## =========================== headless nodes ============================= cam_uv: container_name: "cam-uv-${CAM_FOV}" - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/compose/daq.yml b/compose/daq.yml index 3dc3fee..1d25ab3 100644 --- a/compose/daq.yml +++ b/compose/daq.yml @@ -1,10 +1,9 @@ --- ## Bring up the core nodes (aside from roscore) -version: '3.7' services: daq: container_name: daq - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true devices: - "${MCC_DAQ}:${MCC_DAQ}" diff --git a/compose/detections.yml b/compose/detections.yml index a8e1fb1..7a9f9dd 100644 --- a/compose/detections.yml +++ b/compose/detections.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: ## =========================== headless nodes ============================= detections: - image: kitware/kamera:postproc + image: ${KAMERA_POSTPROC_IMAGE} network_mode: host environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/detector.yml b/compose/detector.yml index af61eab..4723d8d 100644 --- a/compose/detector.yml +++ b/compose/detector.yml @@ -1,13 +1,12 @@ --- ## container configuration for viame interactive building # use compose v2 to use runtime config -version: '2.4' services: ## ========================== viame ============================= detector: container_name: "viame-${CAM_FOV}" - image: kitware/kamera:viame + image: ${KAMERA_VIAME_IMAGE} tty: true environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/flight_summary.yml b/compose/flight_summary.yml index d86d0ae..fb0ba2f 100644 --- a/compose/flight_summary.yml +++ b/compose/flight_summary.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: ## =========================== headless nodes ============================= flight_summary: - image: kitware/kamera:postproc + image: ${KAMERA_POSTPROC_IMAGE} network_mode: host environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/fps_monitor.yml b/compose/fps_monitor.yml index 74e7aa3..b886741 100644 --- a/compose/fps_monitor.yml +++ b/compose/fps_monitor.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: fps_monitor: container_name: fps_monitor - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/compose/gui.yml b/compose/gui.yml index 8f37ae6..f41d133 100644 --- a/compose/gui.yml +++ b/compose/gui.yml @@ -1,11 +1,10 @@ --- ## container configuration for GUI -version: '3.7' services: ## =========================== gui ============================= gui: container_name: gui - image: kitware/kamera:gui + image: ${KAMERA_GUI_IMAGE} tty: true environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/homography.yml b/compose/homography.yml index a10da6a..89c0843 100644 --- a/compose/homography.yml +++ b/compose/homography.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: ## =========================== headless nodes ============================= homography: - image: kitware/kamera:postproc + image: ${KAMERA_POSTPROC_IMAGE} network_mode: host environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/image_manager.yml b/compose/image_manager.yml index 23b156f..b3b78ab 100644 --- a/compose/image_manager.yml +++ b/compose/image_manager.yml @@ -1,11 +1,10 @@ --- ## Auxiliary node to attach to master -version: '3.7' services: ## =========================== headless nodes ============================= image_manager: container_name: "image_manager" - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/imageview.yml b/compose/imageview.yml index e4d5246..a4e171d 100644 --- a/compose/imageview.yml +++ b/compose/imageview.yml @@ -1,9 +1,8 @@ --- -version: '3.7' services: imageview: container_name: "imageview-${CAM_FOV}" - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/ins.yml b/compose/ins.yml index 5d01c04..9f4d3bf 100644 --- a/compose/ins.yml +++ b/compose/ins.yml @@ -1,10 +1,9 @@ --- ## Bring up the core nodes (aside from roscore) -version: '3.7' services: ins: container_name: ins - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true devices: - "${PULSE_TTY}:${PULSE_TTY}" diff --git a/compose/kamerad.yml b/compose/kamerad.yml index 56cde0d..08ba494 100644 --- a/compose/kamerad.yml +++ b/compose/kamerad.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: ## =========================== headless nodes ============================= kamerad: - image: kitware/kamera:kamerad + image: ${KAMERA_KAMERAD_IMAGE} network_mode: host build: ../src/core/kamerad tty: true diff --git a/compose/nodelist.yml b/compose/nodelist.yml index 36f71b4..79c3b74 100644 --- a/compose/nodelist.yml +++ b/compose/nodelist.yml @@ -4,7 +4,7 @@ services: ## =========================== headless nodes ============================= nodelist: container_name: nodelist - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true network_mode: host environment: diff --git a/compose/postproc.yml b/compose/postproc.yml index 9cfe2e7..151c201 100644 --- a/compose/postproc.yml +++ b/compose/postproc.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: ## =========================== headless nodes ============================= postproc: - image: kitware/kamera:postproc + image: ${KAMERA_POSTPROC_IMAGE} network_mode: host environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/registry.yml b/compose/registry.yml index ccbb7cf..728fa45 100644 --- a/compose/registry.yml +++ b/compose/registry.yml @@ -1,4 +1,3 @@ -version: "3" services: registry: restart: always diff --git a/compose/roscore.yml b/compose/roscore.yml index b427a95..2f70ce0 100644 --- a/compose/roscore.yml +++ b/compose/roscore.yml @@ -1,11 +1,10 @@ --- ## Bring up the core nodes -version: '3.7' services: ## =========================== headless nodes ============================= roscore: container_name: roscore - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true network_mode: host environment: diff --git a/compose/shapefile_monitor.yml b/compose/shapefile_monitor.yml index 2814580..12b510a 100644 --- a/compose/shapefile_monitor.yml +++ b/compose/shapefile_monitor.yml @@ -1,10 +1,9 @@ --- ## Core processes -version: '3.7' services: shapefile_monitor: container_name: shapefile_monitor - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true environment: REDIS_HOST: "${REDIS_HOST}" diff --git a/compose/spoof_events.yml b/compose/spoof_events.yml index 831d424..d19bffb 100644 --- a/compose/spoof_events.yml +++ b/compose/spoof_events.yml @@ -1,10 +1,9 @@ --- ## Bring up the core nodes (aside from roscore) -version: '3.7' services: spoof_events: container_name: spoof_events - image: kitware/kamera:core + image: ${KAMERA_CORE_IMAGE} tty: true devices: - "${PULSE_TTY}:${PULSE_TTY}" diff --git a/compose/sync_msg_publisher.yml b/compose/sync_msg_publisher.yml index 4f6124a..7eeb8ed 100644 --- a/compose/sync_msg_publisher.yml +++ b/compose/sync_msg_publisher.yml @@ -1,10 +1,9 @@ --- -version: "3.7" ## =======================image sync publisher=================== services: sync-publisher: container_name: "sync-publisher-${CAM_FOV}" - image: kitware/kamera:viame + image: ${KAMERA_VIAME_IMAGE} tty: true environment: ROS_MASTER_URI: "${ROS_MASTER_URI}" diff --git a/provision/ansible/playbooks/cas/configure.yml b/provision/ansible/playbooks/cas/configure.yml index cb0995b..cba3785 100644 --- a/provision/ansible/playbooks/cas/configure.yml +++ b/provision/ansible/playbooks/cas/configure.yml @@ -5,15 +5,15 @@ - name: Crewed system tasks block: - - name: Clone kamera repo - git: - repo: "git@github.com:Kitware/kamera.git" - dest: "{{ kamera_dir }}" - version: main - recursive: True - accept_hostkey: True - update: True - force: True + # - name: Clone kamera repo + # git: + # repo: "git@github.com:Kitware/kamera.git" + # dest: "{{ kamera_dir }}" + # version: main + # recursive: True + # accept_hostkey: True + # update: True + # force: True - name: "Set redis configuration to {{ kamera_dir }}/src/cfg/redis.conf" become: True @@ -100,13 +100,13 @@ dest: /etc/netplan/{{ inventory_hostname }}-netplan.yaml owner: root - - name: Add mappings to /etc/hosts - become: True - copy: - src: "{{ kamera_dir }}/src/cfg/{{ config_dir }}/{{ inventory_hostname }}/hosts" - remote_src: true - dest: /etc/hosts - owner: root + # - name: Add mappings to /etc/hosts + # become: True + # copy: + # src: "{{ kamera_dir }}/src/cfg/{{ config_dir }}/{{ inventory_hostname }}/hosts" + # remote_src: true + # dest: /etc/hosts + # owner: root # Overwrite default, this is for our 10G cameras - name: Add sysctl rmem params. @@ -196,12 +196,6 @@ when: follower or leader or gui shell: sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target - - name: Create ~/.tmuxinator if it does not exist - file: - path: ~/.tmuxinator - state: directory - mode: '0755' - - name: Create udev rule for mcc_daq become: True when: leader diff --git a/src/cfg/nayak/supervisord.conf b/src/cfg/nayak/supervisord.conf index 48e4054..6b26cda 100644 --- a/src/cfg/nayak/supervisord.conf +++ b/src/cfg/nayak/supervisord.conf @@ -12,6 +12,7 @@ port=0.0.0.0:9001 logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +environment=HOME="/home/user" ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be diff --git a/src/cfg/taiga/supervisord.conf b/src/cfg/taiga/supervisord.conf index 48e4054..6b26cda 100644 --- a/src/cfg/taiga/supervisord.conf +++ b/src/cfg/taiga/supervisord.conf @@ -12,6 +12,7 @@ port=0.0.0.0:9001 logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +environment=HOME="/home/user" ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be diff --git a/src/cfg/uas/supervisord.conf b/src/cfg/uas/supervisord.conf new file mode 100644 index 0000000..8449695 --- /dev/null +++ b/src/cfg/uas/supervisord.conf @@ -0,0 +1,27 @@ +; supervisor config file + +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) +chmod=0700 ; sockef file mode (default 0700) +chown=user:user + +[inet_http_server] +port=0.0.0.0:9001 + +[supervisord] +logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +environment=HOME="/home/user" + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/tmux/nayak/env.sh b/tmux/nayak/env.sh index 3c78721..0a5ab02 100644 --- a/tmux/nayak/env.sh +++ b/tmux/nayak/env.sh @@ -15,16 +15,19 @@ export REDIS_HOST=$(cq ".redis_host") # (without nuvo0, 1, etc. hooked up) # export REDIS_HOST="localhost" -RESP=$(redis-cli -h ${REDIS_HOST} ping) -while [ "$RESP" != "PONG" ] -do - echo "Got '$RESP', wanted 'PONG'." - echo "Waiting for redis host $REDIS_HOST to come online..." - RESP=$(redis-cli -h ${REDIS_HOST} ping) - sleep 1; +_redis_elapsed=0 +RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) +while [ "$RESP" != "PONG" ]; do + if [ $((_redis_elapsed % 30)) -eq 0 ]; then + echo "Waiting for Redis at ${REDIS_HOST} (${_redis_elapsed}s elapsed, got '${RESP}')..." + fi + sleep 1 + _redis_elapsed=$((_redis_elapsed + 1)) + RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) done +unset _redis_elapsed -echo "Redis successfully connected at $REDIS_HOST, starting." +echo "Redis successfully connected at ${REDIS_HOST}, starting." export ROS_MASTER="$(cq .master_host)" export NODE_HOSTNAME=$(hostname) diff --git a/tmux/nayak/follower/config/generic.yml b/tmux/nayak/follower/config/generic.yml deleted file mode 100644 index 0382f47..0000000 --- a/tmux/nayak/follower/config/generic.yml +++ /dev/null @@ -1,35 +0,0 @@ -# tmuxinator configuration file -name: <%= ENV["SESSION"] %> -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/nayak/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/nayak/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker compose -f compose/<%= ENV["SESSION"] %>.yml down - -windows: - - <%= ENV["SESSION"] %>: docker compose -f compose/<%= ENV["SESSION"] %>.yml up <%= ENV["SESSION"] %> diff --git a/tmux/nayak/follower/start_tmux_session.sh b/tmux/nayak/follower/start_tmux_session.sh index 8eea80c..36f9da0 100755 --- a/tmux/nayak/follower/start_tmux_session.sh +++ b/tmux/nayak/follower/start_tmux_session.sh @@ -1,22 +1,24 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -if [ $# != 1 ] -then - echo "Must enter session name." - exit 1 +if [ $# != 1 ]; then + echo "Must enter session name." >&2 + exit 1 fi export SESSION="$1" -# Kills running containers and processes -trap "{ echo Stopping session ${SESSION}; tmuxinator stop ${SESSION}; exit 0; }" EXIT +cleanup() { + echo "Stopping session ${SESSION}" + docker compose -f "${KAMERA_DIR}/compose/${SESSION}.yml" down + tmux kill-session -t "${SESSION}" 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR=$(${HOME}/.config/kamera/repo_dir.bash) echo "Starting session '${SESSION}'." -ln -sf $DIR/config/generic.yml ~/.tmuxinator/${SESSION}.yml +tmux new-session -d -s "${SESSION}" -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker compose -f compose/${SESSION}.yml up ${SESSION}'" -tmuxinator start -n ${SESSION} -p ~/.tmuxinator/${SESSION}.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/nayak/follower/supervisor.conf b/tmux/nayak/follower/supervisor.conf index c694775..693a559 100644 --- a/tmux/nayak/follower/supervisor.conf +++ b/tmux/nayak/follower/supervisor.conf @@ -1,81 +1,68 @@ [program:kamerad] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh kamerad user=user -environment=HOME="/home/user",USER="user" autostart=false [program:image_manager] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh image_manager user=user -environment=HOME="/home/user",USER="user" autostart=false [program:mount_nas] command=/bin/bash /home/user/kw/kamera/tmux/nayak/mount_nas.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:set_eth_speed_max] command=/bin/bash /home/user/kw/kamera/tmux/nayak/set_eth_speed_max.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:cam_ir] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh cam_ir user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_uv] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh cam_uv user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_rgb] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh cam_rgb user=user -environment=HOME="/home/user",USER="user" autostart=false [program:imageview] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh imageview user=user -environment=HOME="/home/user",USER="user" autostart=false [program:fps_monitor] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh fps_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detector] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh detector user=user -environment=HOME="/home/user",USER="user" autostart=false [program:flight_summary] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh flight_summary user=user -environment=HOME="/home/user",USER="user" autostart=false [program:homography] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh homography user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detections] command=/bin/bash /home/user/kw/kamera/tmux/nayak/follower/start_tmux_session.sh detections user=user -environment=HOME="/home/user",USER="user" autostart=false [group:nayak] diff --git a/tmux/nayak/leader/config/generic.yml b/tmux/nayak/leader/config/generic.yml deleted file mode 100644 index e141067..0000000 --- a/tmux/nayak/leader/config/generic.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: <%= ENV["SESSION"] %> -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/nayak/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/nayak/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker compose -f compose/<%= ENV["SESSION"] %>.yml down - -windows: - - <%= ENV["SESSION"] %>: docker compose -f compose/<%= ENV["SESSION"] %>.yml up <%= ENV["SESSION"] %> diff --git a/tmux/nayak/leader/start_tmux_session.sh b/tmux/nayak/leader/start_tmux_session.sh index 8eea80c..36f9da0 100755 --- a/tmux/nayak/leader/start_tmux_session.sh +++ b/tmux/nayak/leader/start_tmux_session.sh @@ -1,22 +1,24 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -if [ $# != 1 ] -then - echo "Must enter session name." - exit 1 +if [ $# != 1 ]; then + echo "Must enter session name." >&2 + exit 1 fi export SESSION="$1" -# Kills running containers and processes -trap "{ echo Stopping session ${SESSION}; tmuxinator stop ${SESSION}; exit 0; }" EXIT +cleanup() { + echo "Stopping session ${SESSION}" + docker compose -f "${KAMERA_DIR}/compose/${SESSION}.yml" down + tmux kill-session -t "${SESSION}" 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR=$(${HOME}/.config/kamera/repo_dir.bash) echo "Starting session '${SESSION}'." -ln -sf $DIR/config/generic.yml ~/.tmuxinator/${SESSION}.yml +tmux new-session -d -s "${SESSION}" -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker compose -f compose/${SESSION}.yml up ${SESSION}'" -tmuxinator start -n ${SESSION} -p ~/.tmuxinator/${SESSION}.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/nayak/leader/supervisor.conf b/tmux/nayak/leader/supervisor.conf index 359aaf6..4677dae 100644 --- a/tmux/nayak/leader/supervisor.conf +++ b/tmux/nayak/leader/supervisor.conf @@ -1,118 +1,99 @@ [program:kamerad] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh kamerad user=user -environment=HOME="/home/user",USER="user" autostart=false [program:image_manager] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh image_manager user=user -environment=HOME="/home/user",USER="user" autostart=false [program:restart_redis] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/restart_redis.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:mount_nas] command=/bin/bash /home/user/kw/kamera/tmux/nayak/mount_nas.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:set_eth_speed_max] command=/bin/bash /home/user/kw/kamera/tmux/nayak/set_eth_speed_max.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:roscore] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh roscore user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_param_monitor] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh cam_param_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:fps_monitor] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh fps_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:shapefile_monitor] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh shapefile_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_ir] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh cam_ir user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_uv] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh cam_uv user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_rgb] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh cam_rgb user=user -environment=HOME="/home/user",USER="user" autostart=false [program:ins] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh ins user=user -environment=HOME="/home/user",USER="user" autostart=false [program:daq] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh daq user=user -environment=HOME="/home/user",USER="user" autostart=false [program:imageview] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh imageview user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detector] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh detector user=user -environment=HOME="/home/user",USER="user" autostart=false [program:flight_summary] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh flight_summary user=user -environment=HOME="/home/user",USER="user" autostart=false [program:homography] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh homography user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detections] command=/bin/bash /home/user/kw/kamera/tmux/nayak/leader/start_tmux_session.sh detections user=user -environment=HOME="/home/user",USER="user" autostart=false [group:nayak] diff --git a/tmux/nayak/startup.sh b/tmux/nayak/startup.sh index 10cbb25..66b9d9b 100755 --- a/tmux/nayak/startup.sh +++ b/tmux/nayak/startup.sh @@ -4,5 +4,4 @@ # . /opt/ros/noetic/setup.sh # rosclean purge -y -mkdir -p ~/.tmuxinator mkdir -p ~/.config/kamera/gui diff --git a/tmux/taiga/env.sh b/tmux/taiga/env.sh index eafb76b..77f2a6f 100644 --- a/tmux/taiga/env.sh +++ b/tmux/taiga/env.sh @@ -14,16 +14,19 @@ export REDIS_HOST=$(cq ".redis_host") # (without nuvo0, 1, etc. hooked up) # export REDIS_HOST="localhost" -RESP=$(redis-cli -h ${REDIS_HOST} ping) -while [ "$RESP" != "PONG" ] -do - echo "Got '$RESP', wanted 'PONG'." - echo "Waiting for redis host $REDIS_HOST to come online..." - RESP=$(redis-cli -h ${REDIS_HOST} ping) - sleep 1; +_redis_elapsed=0 +RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) +while [ "$RESP" != "PONG" ]; do + if [ $((_redis_elapsed % 30)) -eq 0 ]; then + echo "Waiting for Redis at ${REDIS_HOST} (${_redis_elapsed}s elapsed, got '${RESP}')..." + fi + sleep 1 + _redis_elapsed=$((_redis_elapsed + 1)) + RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) done +unset _redis_elapsed -echo "Redis successfully connected at $REDIS_HOST, starting." +echo "Redis successfully connected at ${REDIS_HOST}, starting." export ROS_HOSTNAME=$(cq ".master_host") export NODE_HOSTNAME=$(hostname) diff --git a/tmux/taiga/follower/config/generic.yml b/tmux/taiga/follower/config/generic.yml deleted file mode 100644 index 8286e3e..0000000 --- a/tmux/taiga/follower/config/generic.yml +++ /dev/null @@ -1,35 +0,0 @@ -# tmuxinator configuration file -name: <%= ENV["SESSION"] %> -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/taiga/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/taiga/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker compose -f compose/<%= ENV["SESSION"] %>.yml down - -windows: - - <%= ENV["SESSION"] %>: docker compose -f compose/<%= ENV["SESSION"] %>.yml up <%= ENV["SESSION"] %> diff --git a/tmux/taiga/follower/start_tmux_session.sh b/tmux/taiga/follower/start_tmux_session.sh index 8eea80c..36f9da0 100755 --- a/tmux/taiga/follower/start_tmux_session.sh +++ b/tmux/taiga/follower/start_tmux_session.sh @@ -1,22 +1,24 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -if [ $# != 1 ] -then - echo "Must enter session name." - exit 1 +if [ $# != 1 ]; then + echo "Must enter session name." >&2 + exit 1 fi export SESSION="$1" -# Kills running containers and processes -trap "{ echo Stopping session ${SESSION}; tmuxinator stop ${SESSION}; exit 0; }" EXIT +cleanup() { + echo "Stopping session ${SESSION}" + docker compose -f "${KAMERA_DIR}/compose/${SESSION}.yml" down + tmux kill-session -t "${SESSION}" 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR=$(${HOME}/.config/kamera/repo_dir.bash) echo "Starting session '${SESSION}'." -ln -sf $DIR/config/generic.yml ~/.tmuxinator/${SESSION}.yml +tmux new-session -d -s "${SESSION}" -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker compose -f compose/${SESSION}.yml up ${SESSION}'" -tmuxinator start -n ${SESSION} -p ~/.tmuxinator/${SESSION}.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/taiga/follower/supervisor.conf b/tmux/taiga/follower/supervisor.conf index 8d09a86..bf9b06e 100644 --- a/tmux/taiga/follower/supervisor.conf +++ b/tmux/taiga/follower/supervisor.conf @@ -1,81 +1,68 @@ [program:kamerad] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh kamerad user=user -environment=HOME="/home/user",USER="user" autostart=false [program:image_manager] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh image_manager user=user -environment=HOME="/home/user",USER="user" autostart=false [program:mount_nas] command=/bin/bash /home/user/kw/kamera/tmux/taiga/mount_nas.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:set_eth_speed_max] command=/bin/bash /home/user/kw/kamera/tmux/taiga/set_eth_speed_max.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:cam_ir] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh cam_ir user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_uv] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh cam_uv user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_rgb] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh cam_rgb user=user -environment=HOME="/home/user",USER="user" autostart=false [program:imageview] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh imageview user=user -environment=HOME="/home/user",USER="user" autostart=false [program:fps_monitor] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh fps_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detector] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh detector user=user -environment=HOME="/home/user",USER="user" autostart=false [program:flight_summary] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh flight_summary user=user -environment=HOME="/home/user",USER="user" autostart=false [program:homography] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh homography user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detections] command=/bin/bash /home/user/kw/kamera/tmux/taiga/follower/start_tmux_session.sh detections user=user -environment=HOME="/home/user",USER="user" autostart=false [group:taiga] diff --git a/tmux/taiga/leader/config/generic.yml b/tmux/taiga/leader/config/generic.yml deleted file mode 100644 index 7f8f86d..0000000 --- a/tmux/taiga/leader/config/generic.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: <%= ENV["SESSION"] %> -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/taiga/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/taiga/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker compose -f compose/<%= ENV["SESSION"] %>.yml down - -windows: - - <%= ENV["SESSION"] %>: docker compose -f compose/<%= ENV["SESSION"] %>.yml up <%= ENV["SESSION"] %> diff --git a/tmux/taiga/leader/start_tmux_session.sh b/tmux/taiga/leader/start_tmux_session.sh index 8eea80c..36f9da0 100755 --- a/tmux/taiga/leader/start_tmux_session.sh +++ b/tmux/taiga/leader/start_tmux_session.sh @@ -1,22 +1,24 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -if [ $# != 1 ] -then - echo "Must enter session name." - exit 1 +if [ $# != 1 ]; then + echo "Must enter session name." >&2 + exit 1 fi export SESSION="$1" -# Kills running containers and processes -trap "{ echo Stopping session ${SESSION}; tmuxinator stop ${SESSION}; exit 0; }" EXIT +cleanup() { + echo "Stopping session ${SESSION}" + docker compose -f "${KAMERA_DIR}/compose/${SESSION}.yml" down + tmux kill-session -t "${SESSION}" 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR=$(${HOME}/.config/kamera/repo_dir.bash) echo "Starting session '${SESSION}'." -ln -sf $DIR/config/generic.yml ~/.tmuxinator/${SESSION}.yml +tmux new-session -d -s "${SESSION}" -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker compose -f compose/${SESSION}.yml up ${SESSION}'" -tmuxinator start -n ${SESSION} -p ~/.tmuxinator/${SESSION}.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/taiga/leader/supervisor.conf b/tmux/taiga/leader/supervisor.conf index 5986197..3c14366 100644 --- a/tmux/taiga/leader/supervisor.conf +++ b/tmux/taiga/leader/supervisor.conf @@ -1,118 +1,99 @@ [program:kamerad] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh kamerad user=user -environment=HOME="/home/user",USER="user" autostart=false [program:image_manager] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh image_manager user=user -environment=HOME="/home/user",USER="user" autostart=false [program:restart_redis] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/restart_redis.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:mount_nas] command=/bin/bash /home/user/kw/kamera/tmux/taiga/mount_nas.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:set_eth_speed_max] command=/bin/bash /home/user/kw/kamera/tmux/taiga/set_eth_speed_max.sh startsecs=0 user=root -environment=HOME="/home/user",USER="root" autostart=true [program:roscore] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh roscore user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_param_monitor] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh cam_param_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:fps_monitor] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh fps_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:shapefile_monitor] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh shapefile_monitor user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_ir] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh cam_ir user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_uv] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh cam_uv user=user -environment=HOME="/home/user",USER="user" autostart=false [program:cam_rgb] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh cam_rgb user=user -environment=HOME="/home/user",USER="user" autostart=false [program:ins] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh ins user=user -environment=HOME="/home/user",USER="user" autostart=false [program:daq] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh daq user=user -environment=HOME="/home/user",USER="user" autostart=false [program:imageview] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh imageview user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detector] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh detector user=user -environment=HOME="/home/user",USER="user" autostart=false [program:flight_summary] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh flight_summary user=user -environment=HOME="/home/user",USER="user" autostart=false [program:homography] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh homography user=user -environment=HOME="/home/user",USER="user" autostart=false [program:detections] command=/bin/bash /home/user/kw/kamera/tmux/taiga/leader/start_tmux_session.sh detections user=user -environment=HOME="/home/user",USER="user" autostart=false [group:taiga] diff --git a/tmux/taiga/startup.sh b/tmux/taiga/startup.sh index e029c97..de83212 100644 --- a/tmux/taiga/startup.sh +++ b/tmux/taiga/startup.sh @@ -4,5 +4,4 @@ . /opt/ros/noetic/setup.sh rosclean purge -y -mkdir -p ~/.tmuxinator mkdir -p ~/.config/kamera/gui diff --git a/tmux/uas/env.sh b/tmux/uas/env.sh index 49e8e04..cfbf7a6 100644 --- a/tmux/uas/env.sh +++ b/tmux/uas/env.sh @@ -6,16 +6,19 @@ export REDIS_HOST="uas0" # (without uas0, 1, etc. hooked up) # export REDIS_HOST="localhost" -RESP=$(redis-cli -h ${REDIS_HOST} ping) -while [ "$RESP" != "PONG" ] -do - echo "Got '$RESP', wanted 'PONG'." - echo "Waiting for redis host $REDIS_HOST to come online..." - RESP=$(redis-cli -h ${REDIS_HOST} ping) - sleep 1; +_redis_elapsed=0 +RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) +while [ "$RESP" != "PONG" ]; do + if [ $((_redis_elapsed % 30)) -eq 0 ]; then + echo "Waiting for Redis at ${REDIS_HOST} (${_redis_elapsed}s elapsed, got '${RESP}')..." + fi + sleep 1 + _redis_elapsed=$((_redis_elapsed + 1)) + RESP=$(redis-cli -h "${REDIS_HOST}" ping 2>/dev/null) done +unset _redis_elapsed -echo "Redis successfully connected at $REDIS_HOST, starting." +echo "Redis successfully connected at ${REDIS_HOST}, starting." export NODE_HOSTNAME=$(hostname) export ROS_MASTER_URI="http://${REDIS_HOST}:11311" diff --git a/tmux/uas/follower/00_start_core.sh b/tmux/uas/follower/00_start_core.sh index 0df1a75..e1add96 100755 --- a/tmux/uas/follower/00_start_core.sh +++ b/tmux/uas/follower/00_start_core.sh @@ -2,15 +2,18 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'core'.; tmuxinator stop core; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'core'." + docker-compose -f "${KAMERA_DIR}/compose/core.yml" down + tmux kill-session -t core 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Start session 'core'." -ln -sf $DIR/config/core.yml ~/.tmuxinator/core.yml +tmux new-session -d -s core -n webvideo -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up webvideo'" -tmuxinator start -p $DIR/config/core.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/follower/01_start_sensors.sh b/tmux/uas/follower/01_start_sensors.sh index 37d30f2..84bd631 100755 --- a/tmux/uas/follower/01_start_sensors.sh +++ b/tmux/uas/follower/01_start_sensors.sh @@ -2,15 +2,20 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'sensors'; tmuxinator stop sensors; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'sensors'." + docker-compose -f "${KAMERA_DIR}/compose/sensors.yml" down + tmux kill-session -t sensors 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Starting session 'sensors'." -ln -sf $DIR/config/sensors.yml ~/.tmuxinator/sensors.yml +tmux new-session -d -s sensors -n rgb_cam -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/sensors.yml up cam_rgb'" +tmux new-window -t sensors: -n ir_cam -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/sensors.yml up cam_ir'" -tmuxinator start -n sensors -p $DIR/config/sensors.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/follower/02_start_processing.sh b/tmux/uas/follower/02_start_processing.sh index 63f8887..495dce3 100755 --- a/tmux/uas/follower/02_start_processing.sh +++ b/tmux/uas/follower/02_start_processing.sh @@ -2,15 +2,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'processing'; tmuxinator stop processing; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'processing'." + docker-compose -f "${KAMERA_DIR}/compose/processing.yml" down + tmux kill-session -t processing 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Starting session 'processing'." -ln -sf $DIR/config/processing.yml ~/.tmuxinator/processing.yml +tmux new-session -d -s processing -n viewport_rgb -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up viewport_rgb'" +tmux new-window -t processing: -n viewport_ir -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up viewport_ir'" +tmux new-window -t processing: -n nexus -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up nexus'" -tmuxinator start -n processing -p $DIR/config/processing.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/follower/config/core.yml b/tmux/uas/follower/config/core.yml deleted file mode 100644 index 9ebd770..0000000 --- a/tmux/uas/follower/config/core.yml +++ /dev/null @@ -1,36 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: core -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/core.yml down - -windows: - - webvideo: docker-compose -f compose/core.yml up webvideo diff --git a/tmux/uas/follower/config/processing.yml b/tmux/uas/follower/config/processing.yml deleted file mode 100644 index 22718a4..0000000 --- a/tmux/uas/follower/config/processing.yml +++ /dev/null @@ -1,38 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: processing -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/processing.yml down - -windows: - - viewport_rgb: docker-compose -f compose/processing.yml up viewport_rgb - - viewport_ir: docker-compose -f compose/processing.yml up viewport_ir - - nexus: docker-compose -f compose/processing.yml up nexus diff --git a/tmux/uas/follower/config/sensors.yml b/tmux/uas/follower/config/sensors.yml deleted file mode 100644 index 03bc085..0000000 --- a/tmux/uas/follower/config/sensors.yml +++ /dev/null @@ -1,37 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: sensors -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/sensors.yml down - -windows: - - rgb_cam: docker-compose -f compose/sensors.yml up cam_rgb - - ir_cam: docker-compose -f compose/sensors.yml up cam_ir diff --git a/tmux/uas/follower/supervisor.conf b/tmux/uas/follower/supervisor.conf index 4e13125..ad606ad 100644 --- a/tmux/uas/follower/supervisor.conf +++ b/tmux/uas/follower/supervisor.conf @@ -1,37 +1,31 @@ [program:core] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/00_start_core.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:sensors] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/01_start_sensors.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:processing] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/02_start_processing.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:timesync] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/03_run_clock_sync.sh user=root -environment=HOME="/home/user",USER="root" autostart=true [program:camptp] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/04_run_cam_ptp.sh user=root -environment=HOME="/home/user",USER="root" autostart=true [program:docker] command=/bin/bash /home/user/kw/kamera/tmux/uas/follower/05_start_docker.sh user=root -environment=HOME="/home/user",USER="root" autostart=true [group:uas] diff --git a/tmux/uas/guibox/supervisor.conf b/tmux/uas/guibox/supervisor.conf index 8dcb6d9..d0d2d40 100644 --- a/tmux/uas/guibox/supervisor.conf +++ b/tmux/uas/guibox/supervisor.conf @@ -1,5 +1,4 @@ [program:flight_summary] command=/bin/bash /home/user/kw/kamera/tmux/uas/guibox/00_flight_summary.sh user=root -environment=HOME="/home/user",USER="root" autostart=true diff --git a/tmux/uas/leader/00_start_core.sh b/tmux/uas/leader/00_start_core.sh index 0df1a75..ca7d0f3 100755 --- a/tmux/uas/leader/00_start_core.sh +++ b/tmux/uas/leader/00_start_core.sh @@ -2,15 +2,28 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'core'.; tmuxinator stop core; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'core'." + docker-compose -f "${KAMERA_DIR}/compose/core.yml" down + tmux kill-session -t core 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Start session 'core'." -ln -sf $DIR/config/core.yml ~/.tmuxinator/core.yml +tmux new-session -d -s core -n core -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up roscore'" +tmux new-window -t core: -n webvideo -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up webvideo'" +tmux new-window -t core: -n influxdb -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up influxdb'" +tmux new-window -t core: -n diagnostics -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up diagnostics2influxdb'" +tmux new-window -t core: -n diagnostic_aggregator -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up diagnostic_aggregator'" +tmux new-window -t core: -n cam_param_monitor -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/core.yml up cam_param_monitor'" -tmuxinator start -p $DIR/config/core.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/leader/01_start_sensors.sh b/tmux/uas/leader/01_start_sensors.sh index 37d30f2..7580293 100755 --- a/tmux/uas/leader/01_start_sensors.sh +++ b/tmux/uas/leader/01_start_sensors.sh @@ -2,15 +2,22 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'sensors'; tmuxinator stop sensors; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'sensors'." + docker-compose -f "${KAMERA_DIR}/compose/sensors.yml" down + tmux kill-session -t sensors 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Starting session 'sensors'." -ln -sf $DIR/config/sensors.yml ~/.tmuxinator/sensors.yml +tmux new-session -d -s sensors -n rgb_cam -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/sensors.yml up cam_rgb'" +tmux new-window -t sensors: -n ir_cam -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/sensors.yml up cam_ir'" +tmux new-window -t sensors: -n ins -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/sensors.yml up ins'" -tmuxinator start -n sensors -p $DIR/config/sensors.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/leader/02_start_processing.sh b/tmux/uas/leader/02_start_processing.sh index 63f8887..fdbb03b 100755 --- a/tmux/uas/leader/02_start_processing.sh +++ b/tmux/uas/leader/02_start_processing.sh @@ -2,15 +2,24 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -# Kills running containers and processes -trap "{ echo Stopping session 'processing'; tmuxinator stop processing; exit 0; }" EXIT +cleanup() { + echo "Stopping session 'processing'." + docker-compose -f "${KAMERA_DIR}/compose/processing.yml" down + tmux kill-session -t processing 2>/dev/null +} +trap cleanup EXIT -source $DIR/../env.sh +. "${DIR}/../startup.sh" +export KAMERA_DIR="/home/user/kw/kamera" echo "Starting session 'processing'." -ln -sf $DIR/config/processing.yml ~/.tmuxinator/processing.yml +tmux new-session -d -s processing -n viewport_rgb -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up viewport_rgb'" +tmux new-window -t processing: -n viewport_ir -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up viewport_ir'" +tmux new-window -t processing: -n nexus -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up nexus'" +tmux new-window -t processing: -n shapefile_monitor -c "${KAMERA_DIR}" \ + "bash -c 'source ${DIR}/../env.sh && docker-compose -f compose/processing.yml up shapefile_monitor'" -tmuxinator start -n processing -p $DIR/config/processing.yml - -# Keep process alive for supervisor sleep infinity diff --git a/tmux/uas/leader/config/core.yml b/tmux/uas/leader/config/core.yml deleted file mode 100644 index 5d3bd37..0000000 --- a/tmux/uas/leader/config/core.yml +++ /dev/null @@ -1,41 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: core -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/core.yml down - -windows: - - core: docker-compose -f compose/core.yml up roscore - - webvideo: docker-compose -f compose/core.yml up webvideo - - influxdb: docker-compose -f compose/core.yml up influxdb - - diagnostics: docker-compose -f compose/core.yml up diagnostics2influxdb - - diagnostic_aggregator: docker-compose -f compose/core.yml up diagnostic_aggregator - - cam_param_monitor: docker-compose -f compose/core.yml up cam_param_monitor diff --git a/tmux/uas/leader/config/processing.yml b/tmux/uas/leader/config/processing.yml deleted file mode 100644 index aad3cfd..0000000 --- a/tmux/uas/leader/config/processing.yml +++ /dev/null @@ -1,39 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: processing -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/processing.yml down - -windows: - - viewport_rgb: docker-compose -f compose/processing.yml up viewport_rgb - - viewport_ir: docker-compose -f compose/processing.yml up viewport_ir - - nexus: docker-compose -f compose/processing.yml up nexus - - shapefile_monitor: docker-compose -f compose/processing.yml up shapefile_monitor diff --git a/tmux/uas/leader/config/sensors.yml b/tmux/uas/leader/config/sensors.yml deleted file mode 100644 index 6c3085a..0000000 --- a/tmux/uas/leader/config/sensors.yml +++ /dev/null @@ -1,38 +0,0 @@ -# ~/.tmuxinator/docker.yml - -name: sensors -root: <%= ENV["KAMERA_DIR"] %> - -# Optional tmux socket -# socket_name: foo - -# Runs before everything. Use it to start daemons etc. -on_project_start: . <%= ENV["KAMERA_DIR"] %>/tmux/uas/startup.sh - -# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions. -pre_window: source <%= ENV["KAMERA_DIR"] %>/tmux/uas/env.sh - -# Pass command line options to tmux. Useful for specifying a different tmux.conf. -# tmux_options: -f ~/.tmux.mac.conf - -# Change the command to call tmux. This can be used by derivatives/wrappers like byobu. -# tmux_command: byobu - -# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used. -# startup_window: editor - -# Specitifes (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used. -# startup_pane: 1 - -# Controls whether the tmux session should be attached to automatically. Defaults to true. -attach: false - -# Runs after everything. Use it to attach to tmux with custom options etc. -# post: tmux -CC attach -t docker - -on_project_stop: echo "Stopping tmux" && docker-compose -f compose/sensors.yml down - -windows: - - rgb_cam: docker-compose -f compose/sensors.yml up cam_rgb - - ir_cam: docker-compose -f compose/sensors.yml up cam_ir - - ins: docker-compose -f compose/sensors.yml up ins diff --git a/tmux/uas/leader/supervisor.conf b/tmux/uas/leader/supervisor.conf index f5f2cf7..940c5cd 100644 --- a/tmux/uas/leader/supervisor.conf +++ b/tmux/uas/leader/supervisor.conf @@ -1,31 +1,26 @@ [program:core] command=/bin/bash /home/user/kw/kamera/tmux/uas/leader/00_start_core.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:sensors] command=/bin/bash /home/user/kw/kamera/tmux/uas/leader/01_start_sensors.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:processing] command=/bin/bash /home/user/kw/kamera/tmux/uas/leader/02_start_processing.sh user=user -environment=HOME="/home/user",USER="user" autostart=true [program:timesync] command=/bin/bash /home/user/kw/kamera/tmux/uas/leader/03_run_clock_sync.sh user=root -environment=HOME="/home/user",USER="root" autostart=true [program:docker] command=/bin/bash /home/user/kw/kamera/tmux/uas/leader/05_start_docker.sh user=root -environment=HOME="/home/user",USER="root" autostart=true [group:uas] diff --git a/tmux/uas/startup.sh b/tmux/uas/startup.sh index 0a4ea89..c0ac645 100644 --- a/tmux/uas/startup.sh +++ b/tmux/uas/startup.sh @@ -2,5 +2,4 @@ source /opt/ros/melodic/setup.bash rosclean purge -y -mkdir -p ~/.tmuxinator mkdir -p ~/.config/kamera/gui