Skip to content

Deploying Code

Bennett Petzold edited this page Jun 3, 2023 · 9 revisions

Quick Reference

  • Static IP: 192.168.2.6
  • User: sw8
  • Target IP: 192.168.2.5

1: Setting Laptop Environment

Based on ROS connection method

  • Install Java 11 through a package manager or direct
  • Clone this git repository
  • Attach to target single board computer via Ethernet
    • We use a network switch for multiple connections
      • Creates a local network

2: Gradle Deploy

  • Prerequisite: Task 1
  • Get a copy of ".sw8_ssh_identity"
    • Put it in the "app" directory
    • Ask the software lead for the file
  • Get a copy of ".sw8_password"
    • Put it in the "app" directory
    • Text file with the admin password
  • Use the deploy task
    • Go to the project root
    • Open in command processor (cmd/bash/zsh/etc)
    • Linux/MacOS: ./gradlew deploy
    • Windows: ./gradlew.bat deploy

3: Direct SSH Access

  • Prerequisite: Task 1
  • The target address is 192.168.2.5
  • Use SSH utility
    • Linux/MacOS: use ssh directly
      • ssh sw8@192.168.2.5
      • For graphics: ssh -x sw8@192.168.2.5
    • Windows: use terminal emulator
      • e.g. MobaXTerm
      • User: sw8
      • Host: 192.168.2.5
      • Port: 22
  • Ask for password
  • Optional: add "sw8_ssh_identity" to your ssh agent
    • Password not needed if an identity file is provided
    • Ask the software lead for the file

4: Running Code

  • Prerequisite: Task 3
  • Enter the ~/java directory
    • cd ~/java
  • Run app-all.jar
    • java -jar app-all.jar
    • Include flags after the java run
      • java -jar app-all.jar [flags]
      • e.g. java -jar app-all.jar --help

5: tmux

  • Online manual page
    • If tmux is installed, can access with "man tmux"
    • Our tmux sessions will be left on all defaults
      • GNU screen users: that means CTRL - b, not CTRL - a
  • Purpose of tmux
    • tmux = Terminal Multiplexer
    • Persistent terminal session when connection drops
    • Multiple windows on one connection
    • Generally great tool for terminal work
  • Starting tmux To start a new tmux session: "tmux"
    • To connect to a tmux session: "tmux a" or "tmux a [number]"
    • List tmux sessions: "tmux ls"
    • The tmux environment has a green bar at the bottom of the screen
    • Start tmux sessions on the target, not your machine
      • Don't nest tmux sessions
  • Basic tmux commands
    • All commands start by typing CTRL - b, then the specific command
    • Create new window: CTRL - b c
    • Close window: CTRL - b &
      • Close pane (works for one pane windows): CTRL - b x
    • Go to window N: CTRL - b N
      • e.g. for window 1, CTRL - b 1
    • Detach: CTRL - b d
      • Reattach with "tmux a"
      • When session is over, do not use detach
        • Use the "exit" command in bash
        • CTRL-d (no CTRL - b first) also exits
    • For more detail, see "DEFAULT KEY BINDINGS" in manual

6: Read-Only Platform Mount

  • The system is mounted read-only by default
    • Reduces damage from SD cards degrading on writes
    • Protects against corruption from shutdown during filesystem operations
      • Power loss
      • System crash
      • Filesystems can usually recover, but it's better to not need recovering in the first place
  • In order to change files, we need to remount
    • Two aliases provided, require sudo
      • rw
        • remount as read-write (typical filesystem behavior)
      • ro
        • remount as read-only (default machine behavior)

7: Debugging

  • Can't connect to target device
    • Make sure user is sw8
      • sw8s is wrong
      • Check password
    • Confirm laptop settings
      • Check against [Task 1](# 1: Setting Laptop Environment)
    • Try ping 192.168.2.5
    • Try a network scan
      • sudo rfkill wlan (IMPORTANT)
        • Disconnects from local WiFi
      • sudo nmap -sn 192.168.2.0/24
        • Scan that doesn't test ports
      • sudo nmap 192.168.2.0/24
        • Scan that tests ports
        • Use if ping/fast scan succeeds but connection fails
    • Confirm next step with leadership
      • Likely power cycling the Pi
  • The test phase failed
    • You failed the tests
    • Fix your code or fix the tests
  • Can't run java/deployed app
    • Test if java is on the system
    • Check default java version
      • java --version
      • If not Java 11, replace with Java 11