Last active
April 19, 2019 16:28
-
-
Save bjornbouetsmith/328f3f607ca3af93880d082436eaeda2 to your computer and use it in GitHub Desktop.
NATS installation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
adduser --system --group --no-create-home --shell /bin/false nats | |
mkdir -p /srv/nats/bin | |
mkdir -p /var/log/gnatsd | |
chown -R nats:nats /srv/nats | |
chown -R nats:nats /var/log/gnatsd | |
touch /srv/nats/gnatsd.conf | |
cat <<EOF >/srv/nats/gnatsd.conf | |
http_port: 8222 | |
log_file: "/var/log/gnatsd/gnatsd.log" | |
EOF | |
cat <<EOF > /etc/systemd/system/nats.service | |
[Unit] | |
Description=NATS messaging server | |
[Service] | |
ExecStart=/srv/nats/bin/gnatsd -c /srv/nats/gnatsd.conf | |
User=nats | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<'EOF' >> /etc/logrotate.conf | |
/var/log/gnatsd/gnatsd.log { | |
daily | |
rotate 30 | |
compress | |
missingok | |
notifempty | |
postrotate | |
kill -SIGUSR1 `cat /var/run/gnatsd.pid` | |
endscript | |
} | |
EOF | |
cd /root | |
apt-get install git -y | |
wget https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz | |
tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz | |
#add go to path | |
#edit /etc/profile and add /usr/local/bin to the PATH variable | |
export PATH=$PATH:/usr/local/bin | |
#install nats | |
go get github.com/nats-io/gnatsd | |
cp /root/go/bin/gnatsd /srv/nats/bin/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment