Skip to content

Instantly share code, notes, and snippets.

@pmuellr
Last active January 31, 2021 13:19
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save pmuellr/3854a1a7f17159b432e6 to your computer and use it in GitHub Desktop.
Save pmuellr/3854a1a7f17159b432e6 to your computer and use it in GitHub Desktop.
sample script to install N|Solid components into ~/nsolid
#!/bin/bash
#-------------------------------------------------------------------------------
# download/unpack componentry for N|Solid into ~/nsolid
#-------------------------------------------------------------------------------
# updates:
# 2016-05-04 print note about officially supported "Download All" tarball
# 2016-02-10 change to get N|Solid versions dynamically from index.tab
# 2016-02-10 upgrade to N|Solid 1.2.1
# 2016-01-12 upgrade to N|Solid 1.2.0
# 2015-12-04 upgrade to N|Solid 1.1.1
# 2015-11-18 upgrade to N|Solid 1.1.0
# 2015-10-20 first published
#-------------------------------------------------------------------------------
echo 'As of May 2016, with N|Solid 1.3, you can now download all the N|Solid bits'
echo 'in a single tarball. That tarball includes an `install.sh` script similar'
echo 'to this one. See the "Download All" links at https://downloads.nodesource.com/'
echo ''
echo 'Though this script will continue to work, you probably want to use the'
echo '"Download All" process in the future, as that is officially supported,'
echo 'and this script is not.'
echo ''
#-------------------------------------------------------------------------------
# download/unpack componentry for N|Solid into ~/nsolid
#-------------------------------------------------------------------------------
# directories
DIR_DOWN=~/Downloads
DIR_INST=~/nsolid
# URL prefixes
URL_NSOL=https://nsolid-download.nodesource.com/download
URL_ETCD=https://github.com/coreos/etcd/releases/download
# version #'s
VERSION_ETCD=v2.3.3
VERSION_NSOL=`curl -s https://nsolid-download.nodesource.com/download/nsolid-node/release/index.tab | tail -n +2 | head -n 1 | cut -f2`
VERSION_CONS=`curl -s https://nsolid-download.nodesource.com/download/nsolid-console/release/index.tab | tail -n +2 | head -n 1 | cut -f2`
VERSION_PROX=`curl -s https://nsolid-download.nodesource.com/download/nsolid-proxy/release/index.tab | tail -n +2 | head -n 1 | cut -f2`
echo "downloading N|Solid to ${DIR_DOWN}"
echo "installing N|Solid in ${DIR_INST}"
echo ""
# get os version
if [[ "$OSTYPE" == "linux-gnu" ]]; then
OS=linux
ETCD_EXT=tar.gz
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS=darwin
ETCD_EXT=zip
else
echo "unknown OS, downloading linux"
OS=linux
ETCD_EXT=tar.gz
fi
#-------------------------------------------------------------------------------
# start downloads
#-------------------------------------------------------------------------------
mkdir -p ${DIR_DOWN}
echo "downloading N|Solid Runtime ${VERSION_NSOL}"
curl \
--user-agent nsolid-install.sh \
--location \
--progress-bar \
--output ${DIR_DOWN}/nsolid-node.tar.gz \
${URL_NSOL}/nsolid-node/release/${VERSION_NSOL}/nsolid-${VERSION_NSOL}-${OS}-x64.tar.gz
echo "downloading N|Solid Console ${VERSION_CONS}"
curl \
--user-agent nsolid-install.sh \
--location \
--progress-bar \
--output ${DIR_DOWN}/nsolid-cons.tar.gz \
${URL_NSOL}/nsolid-console/release/${VERSION_CONS}/nsolid-console-${VERSION_CONS}-${OS}-x64.tar.gz
echo "downloading N|Solid Proxy ${VERSION_PROX}"
curl \
--user-agent nsolid-install.sh \
--location \
--progress-bar \
--output ${DIR_DOWN}/nsolid-prox.tar.gz \
${URL_NSOL}/nsolid-proxy/release/${VERSION_PROX}/nsolid-proxy-${VERSION_PROX}.tar.gz
echo "downloading etcd ${VERSION_ETCD}"
curl \
--user-agent nsolid-install.sh \
--location \
--progress-bar \
--output ${DIR_DOWN}/etcd.${ETCD_EXT} \
${URL_ETCD}/${VERSION_ETCD}/etcd-${VERSION_ETCD}-${OS}-amd64.${ETCD_EXT}
#-------------------------------------------------------------------------------
# unpack
#-------------------------------------------------------------------------------
echo ""
echo "unpacking tarballs"
mkdir -p ${DIR_INST}
mkdir -p ${DIR_INST}/console
mkdir -p ${DIR_INST}/proxy
mkdir -p ${DIR_INST}/etcd
rm -rf ${DIR_INST}/console/*
rm -rf ${DIR_INST}/proxy/*
rm -rf ${DIR_INST}/etcd/*
tar --strip-components 1 -zxf ${DIR_DOWN}/nsolid-node.tar.gz -C ${DIR_INST}
tar --strip-components 1 -zxf ${DIR_DOWN}/nsolid-cons.tar.gz -C ${DIR_INST}/console
tar --strip-components 1 -zxf ${DIR_DOWN}/nsolid-prox.tar.gz -C ${DIR_INST}/proxy
tar --strip-components 1 -zxf ${DIR_DOWN}/etcd.${ETCD_EXT} -C ${DIR_INST}/etcd
#-------------------------------------------------------------------------------
# write launch scripts
#-------------------------------------------------------------------------------
#--------------------------------------
echo "writing launch-etcd.sh"
cat > ${DIR_INST}/launch-etcd.sh << END_ETCD_SH
#!/bin/sh
cd ${DIR_INST}/etcd
./etcd
END_ETCD_SH
chmod +x ${DIR_INST}/launch-etcd.sh
#--------------------------------------
echo "writing launch-nsolid-console.sh"
cat > ${DIR_INST}/launch-nsolid-console.sh << END_CONSOLE_SH
#!/bin/sh
cd ${DIR_INST}/console
NODE_ENV=production ../bin/nsolid bin/nsolid-console --interval=3000
END_CONSOLE_SH
chmod +x ${DIR_INST}/launch-nsolid-console.sh
#--------------------------------------
echo "writing launch-proxy.sh"
cat > ${DIR_INST}/launch-nsolid-proxy.sh << END_PROXY_SH
#!/bin/sh
cd ${DIR_INST}/proxy
../bin/nsolid proxy.js
END_PROXY_SH
chmod +x ${DIR_INST}/launch-nsolid-proxy.sh
@pmuellr
Copy link
Author

pmuellr commented Oct 2, 2015

Bash script to:

  • download N|Solid component archives to ~/Downloads
  • install N|Solid components in ~/nsolid
  • write bash launch scripts for etcd, nsolid-proxy, and nsolid-console

Everything is installed into the directory ~/nsolid. First the N|Solid Runtime is unpacked into that directory. The N|Solid executables, including nsolid, node, and npm are installed in the ~/nsolid/bin directory, as with a typical Node.js install. Then etcd, N|Solid Console and N|Solid Proxy are installed in separate subdirectories in that directory, as ~/nsolid/etcd, ~/nsolid/console and ~/nsolid/proxy.

Also installed into ~/nsolid are files launch-etcd.sh, launch-nsolid-console.sh, launch-nsolid-proxy.sh. These files will launch the respective component, with default arguments, in the right working directory.

Once everything is installed, and the components are started, you should be able to display the N|Solid Console at http://localhost:3000. To monitor an app running in the console, use the following
command:

NSOLID_HUB=4001 NSOLID_APPNAME=appName nsolid <program> <args>

The easiest way to test, is to monitor a REPL:

NSOLID_HUB=4001 NSOLID_APPNAME=repl nsolid

If you're on a mac and using the monu process launcher/monitor, the following config file can be used to launch the components:

{
  "logs": "./logs",
  "pids": "./pids",

  "processes": {
    "nsolid-proxy":   "~/nsolid/launch-nsolid-proxy.sh",
    "nsolid-console": "~/nsolid/launch-nsolid-console.sh",
    "etcd":           "~/nsolid/launch-etcd.sh"
  }
}

@mytototo
Copy link

Thanks a lot for sharing! Everything works fine with the latest revision expect snapshots... I can't create a new one. I have this error:

Uh Oh! Looks like the connection to the N|Solid server dropped. You can still use the Console, but functionality is limited.

Is it related to an old version of N|Solid previously installed on my computer?

@pmuellr
Copy link
Author

pmuellr commented Feb 18, 2016

@mytototo in the future, best to ask questions on Stack Overflow, tagging nsolid: http://stackoverflow.com/questions/tagged/nsolid

Seems possible that something is still running an older version of N|Solid that you had installed. Can you remove (or move out of the way) any older versions, and try again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment