Skip to content

Instantly share code, notes, and snippets.

@klauer
Last active January 25, 2021 18:30
Show Gist options
  • Save klauer/b32191212e6ff54a099d1e1aeab13c9b to your computer and use it in GitHub Desktop.
Save klauer/b32191212e6ff54a099d1e1aeab13c9b to your computer and use it in GitHub Desktop.
macOS installation of in-development slac-national-accelerator-laboratory-archiver-datasource-backend

Installing in-development slac-national-accelerator-laboratory-archiver-datasource-backend

Requires

  • macOS
  • homebrew
  • conda

Check out the right branch

git clone https://github.com/n-wbrown/archiver-datasource-backend
cd archiver-datasource-backend
git checkout release-share

TODO: Alternative may be to use nvm in place of conda

install grafana, go

brew install grafana go

use conda to get right nodejs version

conda create -n env python=3.8 nodejs=12.19.0 yarn

takes ~1 min

yarn install

bundles

yarn dev
yarn build

setting up Go from scratch with homebrew

Add to ~/.bashrc:

cat >> ~/.bashrc <<'EOF'
export GOPATH="${HOME}/.go"
## export GOROOT="$(brew --prefix golang)/libexec"
export GOROOT=/usr/local/opt/go/libexec
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"
EOF

Install and bootstrap mage

go get -u -d github.com/magefile/mage
cd $GOPATH/src/github.com/magefile/mage
go run bootstrap.go
$ which mage
/Users/klauer/.go/bin/mage
go get -u github.com/grafana/grafana-plugin-sdk-go

mage -v
mage -l

## ls dist/gpx*
## set plugin directory, allow unsigned loading
sed -i -e 's#^;plugins =.*$#plugins = /usr/local/var/lib/grafana/plugins/#' /usr/local/etc/grafana/grafana.ini
sed -i -e 's/;allow_loading_unsigned_plugins =.*$/allow_loading_unsigned_plugins = slac-national-accelerator-laboratory-archiver-datasource-backend/' /usr/local/etc/grafana/grafana.ini

## ll /usr/local/var/lib/grafana/plugins/

Using the development version by way of a soft link:

ln -sf $PWD/dist /usr/local/var/lib/grafana/plugins/gpx_archiver

SSH config

Add to ~/.ssh/config:

Host pslogin-arch
    HostName pslogin.slac.stanford.edu
    # Archiver API:
    LocalForward 17668 pscaa02:17668

SSH to forward 17668:

ssh pslogin-arch

Start grafana

grafana-osx

Add data source

If using SSH settings above, set as URL:

http://localhost:17668/retrieval

Rebuilding

If you checked out the wrong branch or need to rebuild after doing the above:

yarn install
yarn build

Using released versions

Remove the above soft link, if necessary:

rm -f /usr/local/var/lib/grafana/plugins/gpx_archiver
VERSION=0.0.5
wget https://github.com/n-wbrown/archiver-datasource-backend/releases/download/${VERSION}/archiver-datasource-backend.zip
unzip archiver-datasource-backend.zip -d /usr/local/var/lib/grafana/plugins/gpx_archiver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment