Last active
March 1, 2023 11:36
-
-
Save ifduyue/2ebe43be8d2ea1275abf to your computer and use it in GitHub Desktop.
Install beanstalkd on CentOS 7 / CentOS 8
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
[Unit] | |
Description=Beanstalkd is a simple, fast work queue | |
[Service] | |
User=nobody | |
Restart=always | |
RestartSec=500ms | |
ExecStart=/usr/local/bin/beanstalkd -b /var/lib/beanstalkd | |
LimitNOFILE=10240 | |
[Install] | |
WantedBy=multi-user.target |
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
[Unit] | |
Description=Socket for beanstalkd, a simple, fast work queue | |
[Socket] | |
ListenStream=11300 | |
[Install] | |
WantedBy=sockets.target |
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 | |
# Usage: | |
# | |
# wget -O- https://gist.githubusercontent.com/ifduyue/2ebe43be8d2ea1275abf/raw/install-beanstalkd-allinone.sh | bash -s | |
# ...or... | |
# curl -sSL https://gist.githubusercontent.com/ifduyue/2ebe43be8d2ea1275abf/raw/install-beanstalkd-allinone.sh | bash -s | |
# | |
# Set options: | |
# {wget or curl like above...} | beanstalkd_opt='-b /var/lib/beanstalkd -f0' bash -s | |
# | |
# | |
# Use: beanstalkd [OPTIONS] | |
# | |
# Options: | |
# -b DIR write-ahead log directory | |
# -f MS fsync at most once every MS milliseconds (default is 50ms); | |
# use -f0 for "always fsync" | |
# -F never fsync | |
# -l ADDR listen on address (default is 0.0.0.0) | |
# -p PORT listen on port (default is 11300) | |
# -u USER become user and group | |
# -z BYTES set the maximum job size in bytes (default is 65535); | |
# max allowed is 1073741824 bytes | |
# -s BYTES set the size of each write-ahead log file (default is 10485760); | |
# will be rounded up to a multiple of 4096 bytes | |
# -v show version information | |
# -V increase verbosity | |
# -h show this help | |
# | |
set -eu | |
version=1.12 | |
beanstalkd_opt=${beanstalkd_opt--b /var/lib/beanstalkd} | |
wget -O v$version.tar.gz https://github.com/beanstalkd/beanstalkd/archive/v$version.tar.gz | |
tar xf v$version.tar.gz | |
make -C beanstalkd-$version | |
make install -C beanstalkd-$version | |
rm -rf beanstalkd-$version v$version.tar.gz | |
if [[ ! -f /etc/systemd/system/beanstalkd.service ]]; then | |
cat > /etc/systemd/system/beanstalkd.service <<EOF | |
[Unit] | |
Description=Beanstalkd is a simple, fast work queue | |
[Service] | |
User=nobody | |
Restart=always | |
RestartSec=500ms | |
ExecStart=/usr/local/bin/beanstalkd $beanstalkd_opt | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
fi | |
if [[ ! -f /etc/systemd/system/beanstalkd.socket ]]; then | |
cat > /etc/systemd/system/beanstalkd.socket <<EOF | |
[Unit] | |
Description=Socket for beanstalkd, a simple, fast work queue | |
[Socket] | |
ListenStream=11300 | |
[Install] | |
WantedBy=sockets.target | |
EOF | |
fi | |
valdir=$(echo -- $beanstalkd_opt | grep -Po -- '-b \K[^ ]+') || true | |
if [[ -n "$valdir" ]]; then | |
mkdir -p $valdir | |
chown nobody:nobody $valdir | |
fi | |
systemctl enable beanstalkd.service | |
systemctl start beanstalkd.service |
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 -eu | |
version=1.12 | |
wget -O v$version.tar.gz https://github.com/beanstalkd/beanstalkd/archive/v$version.tar.gz | |
tar xf v$version.tar.gz | |
make -C beanstalkd-$version | |
make install -C beanstalkd-$version | |
rm -rf beanstalkd-$version v$version.tar.gz | |
if [[ -f beanstalkd.service && -f beanstalkd.socket ]]; then | |
cp beanstalkd.service /etc/systemd/system/beanstalkd.service | |
cp beanstalkd.socket /etc/systemd/system/beanstalkd.socket | |
mkdir -p /var/lib/beanstalkd | |
chown nobody:nobody /var/lib/beanstalkd | |
systemctl enable beanstalkd.service | |
systemctl start beanstalkd.service | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice @ifduyue , works on CentOS 9 too 🎉