net/lavinmq: new port AMQP-compliant message broker

High performance AMQP-0.9.1 compatible, written in Crystal.

Differential Revision: https://reviews.freebsd.org/D31410
This commit is contained in:
Dave Cottlehuber 2023-01-11 22:01:21 +00:00
parent 2d9ecbe7c5
commit 9bf4ac1466
9 changed files with 239 additions and 2 deletions

2
GIDs
View File

@ -255,7 +255,7 @@ _arti:*:311:
_sphinx:*:312:
_fastdfs:*:313:
promscale:*:314:
# free: 315
lavinmq:*:315:
# free: 316
# free: 317
# free: 318

2
UIDs
View File

@ -260,7 +260,7 @@ _arti:*:311:311::0:0:Arti Daemon:/nonexistent:/usr/sbin/nologin
_sphinx:*:312:312::0:0:Sphinxsearch Owner:/nonexistent:/usr/sbin/nologin
_fastdfs:*:313:313::0:0:FastDFS Owner:/nonexistent:/usr/sbin/nologin
promscale:*:314:314::0:0:Promscale:/nonexistent:/usr/sbin/nologin
# free: 315
lavinmq:*:315:315::0:0:LavinMQ user:/nonexistent:/usr/sbin/nologin
# free: 316
# free: 317
# free: 318

View File

@ -346,6 +346,7 @@
SUBDIR += lambdamoo
SUBDIR += landrop
SUBDIR += latd
SUBDIR += lavinmq
SUBDIR += ldap-stats
SUBDIR += ldapbrowser
SUBDIR += ldapdiff

88
net/lavinmq/Makefile Normal file
View File

@ -0,0 +1,88 @@
PORTNAME= lavinmq
DISTVERSIONPREFIX= v
DISTVERSION= 1.0.0-beta.8
CATEGORIES= net
PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
# PATCHFILES+= 3a73c414b749.patch:-p1 # https://github.com/cloudamqp/lavinmq/pull/273
MAINTAINER= dch@FreeBSD.org
COMMENT= Next-generation AMQP 0.9.1 based message broker
LICENSE= APACHE20
BUILD_DEPENDS= crystal:lang/crystal \
help2man:misc/help2man \
shards:devel/shards
USES= pkgconfig ssl:build
USE_GITHUB= yes
GH_ACCOUNT= cloudamqp
GH_TUPLE= \
84codes:http-protection:893a191d55e301e0df96d6dd0f7d72c527bddeb8:a/deps/http-protection \
84codes:systemd.cr:v2.0.0:systemd/deps/systemd.cr \
cloudamqp:amq-protocol.cr:v1.1.2:proto/deps/amq-protocol.cr \
cloudamqp:amqp-client.cr:v1.0.9:client/deps/amqp-client.cr \
luislavena:radix:v0.4.1:radix/deps/radix \
schovi:baked_file_system:v0.10.0:baked/deps/baked_file_system \
tbrand:router.cr:v0.2.8:router/deps/router.cr
USE_RC_SUBR= lavinmq
USERS= lavinmq
GROUPS= lavinmq
PORTDOCS= CHANGELOG.md NOTICE README.md SECURITY.md
OPTIONS_DEFINE= DOCS
SHARDS_ENV= --time --verbose --production --release --no-color --stats --static
post-extract:
# force shards to use local paths, not git repos, for dependencies
@${RM} ${WRKSRC}/shard.lock
@${REINPLACE_CMD} -E \
-e 's,github: .*/,path: deps/,' \
-e '/branch:/d' \
-e '/version: .>1/d' \
${WRKSRC}/shard.yml ${WRKSRC}/deps/*/shard.yml
# switch config example into hier(5) compliance
@${REINPLACE_CMD} -E \
-e 's,/etc/,${PREFIX}/etc/,' \
-e 's,/lib/,/db/,' \
-e 's,/tmp/lavinmq-http.sock,/var/run/lavinmq/http.sock,' \
-e 's,/tmp/lavinmq.sock,/var/run/lavinmq/amqp.sock,' \
${WRKSRC}/extras/config.ini
do-build:
${MKDIR} ${WRKDIR}/man1
(cd ${WRKSRC} && ${LOCALBASE}/bin/shards lock ${SHARDS_ENV} \
&& ${LOCALBASE}/bin/shards build ${SHARDS_ENV})
help2man -Nn "fast and advanced message queue server" \
${WRKSRC}/bin/lavinmq -o ${WRKDIR}/man1/lavinmq.1
help2man -Nn "control utility for lavinmq server" \
${WRKSRC}/bin/lavinmqctl -o ${WRKDIR}/man1/lavinmqctl.1
help2man -Nn "performance testing tool for amqp servers" \
${WRKSRC}/bin/lavinmqperf -o ${WRKDIR}/man1/lavinmqperf.1
do-install:
${MKDIR} ${STAGEDIR}${ETCDIR} \
${STAGEDIR}/var/db/lavinmq \
${STAGEDIR}/var/log/lavinmq \
${STAGEDIR}${MAN1PREFIX}/man/man1
${INSTALL_DATA} ${WRKSRC}/extras/config.ini \
${STAGEDIR}${ETCDIR}/config.ini.sample
.for f in lavinmq lavinmqctl lavinmqperf
${INSTALL_PROGRAM} ${WRKSRC}/bin/${f} \
${STAGEDIR}${PREFIX}/bin
${INSTALL_MAN} ${WRKDIR}/man1/${f}.1 ${STAGEDIR}${MAN1PREFIX}/man/man1/
.endfor
do-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
.for f in ${PORTDOCS}
${INSTALL_DATA} ${WRKSRC}/${f} \
${STAGEDIR}${DOCSDIR}
.endfor
.include <bsd.port.mk>

17
net/lavinmq/distinfo Normal file
View File

@ -0,0 +1,17 @@
TIMESTAMP = 1672656176
SHA256 (cloudamqp-lavinmq-v1.0.0-beta.8_GH0.tar.gz) = e0c7a90bc0b240f2dcf118a9c922c4b0ee604f19dfb2ed0b7137cb73af8abe3b
SIZE (cloudamqp-lavinmq-v1.0.0-beta.8_GH0.tar.gz) = 707858
SHA256 (84codes-http-protection-893a191d55e301e0df96d6dd0f7d72c527bddeb8_GH0.tar.gz) = eba9fed6dff8ed2b1322ca57b5bdd1e6d4afe49367ca84f38cd0cd7c062dab93
SIZE (84codes-http-protection-893a191d55e301e0df96d6dd0f7d72c527bddeb8_GH0.tar.gz) = 10307
SHA256 (84codes-systemd.cr-v2.0.0_GH0.tar.gz) = 4dd0c6f838542f97338866aef36de7b464c06112c4434e4db48aa65586b68ef3
SIZE (84codes-systemd.cr-v2.0.0_GH0.tar.gz) = 4339
SHA256 (cloudamqp-amq-protocol.cr-v1.1.2_GH0.tar.gz) = 23c1f3bd2c611a4249fc4a5438db2d68d647dfef900138675aabdc0e4a122ca5
SIZE (cloudamqp-amq-protocol.cr-v1.1.2_GH0.tar.gz) = 15611
SHA256 (cloudamqp-amqp-client.cr-v1.0.9_GH0.tar.gz) = 9c7cbcd390b353ac9e138d669ec251236341c0f8ccf18b190f37b46f16a5c0d8
SIZE (cloudamqp-amqp-client.cr-v1.0.9_GH0.tar.gz) = 19647
SHA256 (luislavena-radix-v0.4.1_GH0.tar.gz) = 5f207eb769101d94726eb476eb5f9b4603482c7941396ab4c85866722b7497b1
SIZE (luislavena-radix-v0.4.1_GH0.tar.gz) = 13847
SHA256 (schovi-baked_file_system-v0.10.0_GH0.tar.gz) = ea63c25b5327817bb494edb3e74950a42a4a50efc25e8035292f15f1e3039a50
SIZE (schovi-baked_file_system-v0.10.0_GH0.tar.gz) = 56007
SHA256 (tbrand-router.cr-v0.2.8_GH0.tar.gz) = a64540dbd57bc2feba50a432b37d3647f4ab72ee16058746623f3f024b5f3f25
SIZE (tbrand-router.cr-v0.2.8_GH0.tar.gz) = 5132

View File

@ -0,0 +1,94 @@
#!/bin/sh
# PROVIDE: lavinmq
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# lavinmq_enable (bool): Set it to YES to enable lavinmq.
# Default is "NO".
# lavinmq_user (user): Set user to run lavinmq.
# Default is "lavinmq".
# lavinmq_group (group): Set group to run lavinmq.
# Default is "lavinmq".
# lavinmq_config (file): Set lavinmq config file.
# Default is "%%ETCDIR%%/lavinmq.conf".
# lavinmq_syslog_output_enable (bool): Set to enable syslog output.
# Default is "NO". See daemon(8).
# lavinmq_syslog_output_priority (str): Set syslog priority if syslog enabled.
# Default is "info". See daemon(8).
# lavinmq_syslog_output_facility (str): Set syslog facility if syslog enabled.
# Default is "daemon". See daemon(8).
. /etc/rc.subr
name=lavinmq
rcvar=lavinmq_enable
load_rc_config $name
: ${lavinmq_enable:="NO"}
: ${lavinmq_dir:="/var/db/lavinmq"}
: ${lavinmq_run:="/var/run/lavinmq"}
: ${lavinmq_user:="lavinmq"}
: ${lavinmq_group:="lavinmq"}
: ${lavinmq_config:="%%ETCDIR%%/config.ini"}
DAEMON=$(/usr/sbin/daemon 2>&1 | grep -q syslog ; echo $?)
if [ ${DAEMON} -eq 0 ]; then
: ${lavinmq_syslog_output_enable:="NO"}
: ${lavinmq_syslog_output_priority:="info"}
: ${lavinmq_syslog_output_facility:="daemon"}
if checkyesno lavinmq_syslog_output_enable; then
lavinmq_syslog_output_flags="-T ${name}"
if [ -n "${lavinmq_syslog_output_priority}" ]; then
lavinmq_syslog_output_flags="${lavinmq_syslog_output_flags} -s ${lavinmq_syslog_output_priority}"
fi
if [ -n "${lavinmq_syslog_output_facility}" ]; then
lavinmq_syslog_output_flags="${lavinmq_syslog_output_flags} -l ${lavinmq_syslog_output_facility}"
fi
fi
else
lavinmq_syslog_output_enable="NO"
lavinmq_syslog_output_flags=""
fi
pidfile=/var/run/lavinmq/daemon.pid
procname="%%PREFIX%%/bin/lavinmq"
command="/usr/sbin/daemon"
command_args="-f -t ${name} ${lavinmq_syslog_output_flags} -p ${pidfile} /usr/bin/env ${lavinmq_env} ${procname} --config=${lavinmq_config}"
extra_commands="reload monitor"
monitor_cmd=lavinmq_monitor
start_precmd=lavinmq_startprecmd
required_files="$lavinmq_config"
lavinmq_monitor()
{
sig_reload=USR1
run_rc_command "reload"
}
lavinmq_startprecmd()
{
if [ ! -d ${lavinmq_run} ]; then
install -d -o ${lavinmq_user} -g ${lavinmq_group} ${lavinmq_run}
fi
if [ ! -d ${lavinmq_dir} ]; then
install -d -o ${lavinmq_user} -g ${lavinmq_group} ${lavinmq_dir}
fi
if [ ! -e ${pidfile} ]; then
install -o ${lavinmq_user} -g ${lavinmq_group} /dev/null ${pidfile};
fi
# remove stray sockets that can block startup
rm -rf ${lavinmq_run}/*.sock /tmp/lavinmq
}
run_rc_command "$1"

View File

@ -0,0 +1,11 @@
--- src/lavinmqperf.cr.orig 2023-01-02 14:26:00 UTC
+++ src/lavinmqperf.cr
@@ -482,7 +482,7 @@ class ConnectionCount < Perf
private def client : AMQP::Client
client = @client ||= AMQP::Client.new(@uri)
- client.host = "127.0.#{Random.rand(UInt8)}.#{Random.rand(UInt8)}" if @random_localhost
+ # client.host = "127.0.#{Random.rand(UInt8)}.#{Random.rand(UInt8)}" if @random_localhost
client
end

16
net/lavinmq/pkg-descr Normal file
View File

@ -0,0 +1,16 @@
LavinMQ is a message queue server, also called a message broker, compatible
with the AMQP0.9 spec, where messages are published by a sending service called
a producer, via the broker, to then be consumed by the receiving service called
a consumer. When not handling messages, the queue can route, buffer, and
persist the messages according to rules set up by the user.
Messages can be sent across languages, platforms, and OS, which decouple
processes and creates a highly scalable system. lavinmq, as queue management
software, gives an organized, safe place for messages to wait until another
application or part of the system can come along and consume them for
processing.
lavinmq is written in Crystal, a statically compiled LLVM-based
language with a ruby-like syntax.
WWW: https://www.lavinmq.com/

10
net/lavinmq/pkg-plist Normal file
View File

@ -0,0 +1,10 @@
@dir(lavinmq,lavinmq,750) %%ETCDIR%%
@dir(lavinmq,lavinmq,750) /var/db/lavinmq
@dir(lavinmq,lavinmq,750) /var/log/lavinmq
@sample %%ETCDIR%%/config.ini.sample
bin/lavinmq
bin/lavinmqctl
bin/lavinmqperf
man/man1/lavinmq.1.gz
man/man1/lavinmqctl.1.gz
man/man1/lavinmqperf.1.gz