Last active
November 4, 2020 07:52
-
-
Save crazytaxii/8f6e9dadc9e12ad0b51b30a9c156863d to your computer and use it in GitHub Desktop.
nsq-deploy.sh
This file contains 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/bash | |
set -e | |
download_nsq() { | |
wget -O /tmp/nsq-1.2.0.linux-amd64.go1.12.9.tar.gz https://github.com/nsqio/nsq/releases/download/v1.2.0/nsq-1.2.0.linux-amd64.go1.12.9.tar.gz | |
tar xvzf /tmp/nsq-1.2.0.linux-amd64.go1.12.9.tar.gz -C /tmp/ | |
mv /tmp/nsq-1.2.0.linux-amd64.go1.12.9/bin/* /usr/local/bin | |
rm -rf /tmp/nsq-1.2.0.linux-amd64.go1.12.9 | |
} | |
setup_nsqlookupd() { | |
cat > /etc/systemd/system/nsqlookupd.service <<EOF | |
[Unit] | |
Description=nsqlookupd | |
Documentation=https://github.com/nsqio/nsq | |
After=network.target | |
[Service] | |
ExecStart=/usr/local/bin/nsqlookupd -tcp-address=127.0.0.1:4160 -http-address=127.0.0.1:4161 | |
ExecReload=/bin/kill -HUP $MAINPID | |
Type=simple | |
KillMode=process | |
Restart=on-failure | |
RestartSec=10s | |
User=root | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload | |
systemctl start nsqlookupd | |
} | |
setup_nsqd() { | |
cat > /etc/systemd/system/nsqd.service <<EOF | |
[Unit] | |
Description=nsqd | |
Documentation=https://github.com/nsqio/nsq | |
After=network.target | |
[Service] | |
ExecStart=/usr/local/bin/nsqd -http-address=127.0.0.1:4151 -tcp-address=127.0.0.1:4150 -lookupd-tcp-address=127.0.0.1:4160 | |
ExecReload=/bin/kill -HUP $MAINPID | |
Type=simple | |
KillMode=process | |
Restart=on-failure | |
RestartSec=10s | |
User=root | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload | |
systemctl start nsqd | |
} | |
setup_nsqadmin() { | |
cat > /etc/systemd/system/nsqadmin.service <<EOF | |
[Unit] | |
Description=nsqadmin | |
Documentation=https://github.com/nsqio/nsq | |
After=network.target | |
[Service] | |
ExecStart=/usr/local/bin/nsqadmin --lookupd-http-address=127.0.0.1:4161 | |
ExecReload=/bin/kill -HUP $MAINPID | |
Type=simple | |
KillMode=process | |
Restart=on-failure | |
RestartSec=10s | |
User=root | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
systemctl daemon-reload | |
systemctl start nsqadmin | |
} | |
main() { | |
download_nsq | |
setup_nsqlookupd | |
setup_nsqd | |
setup_nsqadmin | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment