Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi support #20

Open
4 of 10 tasks
KevinSnyderCodes opened this issue Jun 21, 2018 · 3 comments
Open
4 of 10 tasks

Raspberry Pi support #20

KevinSnyderCodes opened this issue Jun 21, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@KevinSnyderCodes
Copy link
Collaborator

KevinSnyderCodes commented Jun 21, 2018

kqstats can persistently run on a Raspberry Pi that is on the same network as the Killer Queen cabinet. This is beneficial for a number of reasons:

  • No need to run kqstats on your local machine -- it's always running on the network!
  • Webpages showing real-time statistics can be accessed by anyone on the network
  • Because of this, new types of webpages would make sense:
    • Stats for a single player (useful for a player to have on their phone screen)
    • Others?

Getting this to work will be a multi-step process:

  • Make kqstats persistent
    • Auto determine the cab's IP address (by finding a local IP address with port 12749 open)
    • Auto connect to cab
    • Reconnect when connection is lost
    • Self-updating
  • Create procedure to set up kqstats on a Raspberry Pi (e.g. shell script)
    • Make the kqstats webpages accessible by the Raspberry Pi's hostname using mDNS
  • Document setup procedure
    • Create network architecture diagram, explaining how the Raspberry Pi sits on the same network as the cab
    • Provide instructions for setting up kqstats on a Raspberry Pi

There may be other steps required.

Resources

@KevinSnyderCodes KevinSnyderCodes added the enhancement New feature or request label Jun 21, 2018
@KevinSnyderCodes KevinSnyderCodes self-assigned this Jun 21, 2018
@KevinSnyderCodes KevinSnyderCodes changed the title Raspberry Pi architecture Raspberry Pi support Jun 21, 2018
@whod81 whod81 self-assigned this Aug 30, 2018
@whod81
Copy link
Collaborator

whod81 commented Sep 4, 2018

Just making some notes. I'm pretty sure there are some more apt-get's in here to get Node installed.

mDNS instructions:

Update Hostname (kqstats) and Update Pi

sudo vi /etc/hostname
sudo vi /etc/hosts
sudo apt-get update
sudo apt-get -y dist-upgrade
sudp apt-get -y install avahi-daemon build-essential
reboot

Intall NODE-RED

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

Get KQStats

git clone https://github.com/killer-queen-stats/kqstats
cd kqstats

Node Install (This takes a while)

npm audit fix
npm install

Create a service

sudo -s
cat > /lib/systemd/system/kqstats.service << EOF
[Unit]
Description=KQ Stats
After=multi-user.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/kqstats
ExecStart=/bin/bash -ce 'exec /usr/bin/npm run start:debug -- -c ws://kq.local:12749 >> /home/pi/kqstats/logs/kqstats.log 2>&1'
Restart=on-abort

[Install]
WantedBy=multi-user.target
EOF

Start Service

sudo systemctl daemon-reload
sudo systemctl enable kqstats.service
sudo systemctl start kqstats.service

@whod81
Copy link
Collaborator

whod81 commented Sep 18, 2018

** Update ***
This is no longer an issue if you run "npm audit fix" before doing the install..... node-sass is no longer a dependency.

** Original Message **

Current issue is that the npm install basically bricks the Pi. Need a way to cross-compile elsewhere and then deliver it.

This would help tremendously:
sass/node-sass#1609

@whod81
Copy link
Collaborator

whod81 commented Feb 14, 2019

#!/bin/sh
REPODIR="/home/pi/repo"
HOMEDIR="/home/pi"
BRANCH=""

# Setting the nice value to as low priority as possible
# The npm install tends to hog up all resources

renice -n 10 $$

[[ `whoami` != "root" ]] && SUDO="/usr/bin/sudo"


if [[ ! -d ${REPODIR} ]]
then
    mkdir -p ${REPODIR}
fi

cd ${REPODIR}
[[ -d ${REPODIR}/kqstats ]] && ${SUDO} rm -rf ${REPODIR}/kqstats

if [[ ${BRANCH} ]]
then
    BRANCH_STR="-b ${BRANCH}"
fi

git clone  https://github.com/killer-queen-stats/kqstats ${BRANCH_STR}
cd ${REPODIR}/kqstats
npm audit fix
npm install
NPMRC=$?

if [[ ! -d ${REPODIR}/kqstats ]]
then
    echo "could not find ${REPODIR}/kqstats.  Exiting."
    exit 1
fi

if [[ $NPMRC == 0 ]]
then
    [[ -d ${HOMEDIR}/kqstats.3.old ]] && rm -rf ${HOMEDIR}/kqstats.3.old
    [[ -d ${HOMEDIR}/kqstats.2.old ]] && mv ${HOMEDIR}/kqstats.2.old ${HOMEDIR}/kqstats.3.old
    [[ -d ${HOMEDIR}/kqstats.1.old ]] && mv ${HOMEDIR}/kqstats.1.old ${HOMEDIR}/kqstats.2.old
    $SUDO systemctl stop kqstats.service
    [[ -d ${HOMEDIR}/kqstats ]] && mv ${HOMEDIR}/kqstats ${HOMEDIR}/kqstats.1.old
    mv ${REPODIR}/kqstats ${HOMEDIR}
    $SUDO chown -R pi:pi ${HOMEDIR}/kqstats
    $SUDO systemctl start kqstats.service
else
    echo "npm intall returned non-zero return code."
    exit 2
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants