From nobody Mon Feb 19 10:09:42 2024 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TddYy2mgbz5BLS8; Mon, 19 Feb 2024 10:09:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TddYy2G27z4hpM; Mon, 19 Feb 2024 10:09:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708337382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XSsjBCxw/++qh6RVtJ3RQfua22iAz7ktpj4MFabN7Q4=; b=eb4hhjqyTqTgBcHRqsEH9qMH2yqYEEQ//tKeQEyRbZyqbzzj/rAcJxFf8N5U8OtoLoTEQ4 sJpH3mmErwIqQWiTysrfCH2BkXbmmq4Hry7g7R6S4X+aSYTFM/xIyb6Xl90FcMluJztmGz Mn33ZUkHksss3FdR3/klvPjckpAMx1NnQ2C2CykFe9e6c+tBMfIuzfw/8DuiWUCfD4gzKP Hnmf0TLzTafTFJB9LFOAQMLbU++8w4v5bMkhSuHkGS9E6r7S6rPiQpjPR3HwnlqJ0s977M ikqWp0ndCD2VTMnDzzYaKu3gDzj8bxmEA/CHWxOllrVREkxGsM2WjsNcY7Ri+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708337382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XSsjBCxw/++qh6RVtJ3RQfua22iAz7ktpj4MFabN7Q4=; b=qZGB76yxeQzlhUsG/Sdj9VaKaw11uFwZyDeg/bMx+U/WxksWZaUmUA39KB4KhJWjqSA5x0 5xbskZ81L0K5+attV/ld32mFpHkw/xjDSdQmO4wkn/5Y+m3uiXfzPrXtTdMp/N0pFihIw8 /PCECNGeHGM9SnbfWbDh5Z5sXDfbvEKOyoKaEaWRx01gdP9tY1Y1W6RS6lncJFb9ANUrF2 BjOK16KSMMmCT21xldZ06iIYZrclbj2VtPik8/LZPoSv3pP+uitEuVpaL+2w+gR2eaD1zx dQ08JmQapIy8Hu4/OmWGNP2jh9fsVEO/AN/tX2xvMSp8/BONITAOIpzGNrMJ5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708337382; a=rsa-sha256; cv=none; b=VZOQdY4EMBxstbEbCeDsNMf/CYrf/UA3X2eeiFnfP8u1FCGiElZrn0wD/TOOp2xQy40qes JKjjaja9JwRemvwklrD0ywtk5vTwWEcNY/I3SHKUcvoCKhyakVmKldczi3cSLejY/ja2hR f7jBKwSCGQjERQAh+0zaL3ycf6n5xqu7kO0Y+vipwDSZYDt11xWV88jEo5fIavo5h465+o g5Hkq9+nMI0ab3bE6XqWC2WXZNDA0KnznlyXehRX6F49SUEXXIvR/ZqW2Y2BXabKuwytQp lFCdNMBW4mszi2aTLQYPIzPVNsQiF/+2iWWBe6K5M/oZwvPuBxqZ1tZ5HY7D3w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TddYy1J9QzV9B; Mon, 19 Feb 2024 10:09:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41JA9g89018929; Mon, 19 Feb 2024 10:09:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JA9gt6018926; Mon, 19 Feb 2024 10:09:42 GMT (envelope-from git) Date: Mon, 19 Feb 2024 10:09:42 GMT Message-Id: <202402191009.41JA9gt6018926@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: 72d7dcd1e59c - main - databases/greptimedb: Add RC script, config files, DB and log directories List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72d7dcd1e59c4283ee0c33592da99d39df47c88b Auto-Submitted: auto-generated The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=72d7dcd1e59c4283ee0c33592da99d39df47c88b commit 72d7dcd1e59c4283ee0c33592da99d39df47c88b Author: Yuri Victorovich AuthorDate: 2024-02-19 08:50:24 +0000 Commit: Yuri Victorovich CommitDate: 2024-02-19 10:09:39 +0000 databases/greptimedb: Add RC script, config files, DB and log directories --- databases/greptimedb/Makefile | 26 +++++-- databases/greptimedb/files/greptimedb.in | 126 +++++++++++++++++++++++++++++++ databases/greptimedb/pkg-plist | 9 +++ 3 files changed, 156 insertions(+), 5 deletions(-) diff --git a/databases/greptimedb/Makefile b/databases/greptimedb/Makefile index efe5ce2b3314..da4d89b98563 100644 --- a/databases/greptimedb/Makefile +++ b/databases/greptimedb/Makefile @@ -2,6 +2,7 @@ PORTNAME= greptimedb DISTVERSIONPREFIX= v DISTVERSION= 0.7.0-nightly-20240115-102 DISTVERSIONSUFFIX= -g29f11d7b7e +PORTREVISION= 1 CATEGORIES= databases MAINTAINER= yuri@FreeBSD.org @@ -18,6 +19,7 @@ BUILD_DEPENDS= gmake:devel/gmake \ LIB_DEPENDS= libzstd.so:archivers/zstd USES= cargo +USE_RC_SUBR= greptimedb USE_GITHUB= yes GH_ACCOUNT= GreptimeTeam @@ -950,20 +952,34 @@ CARGO_CRATES= Inflector-0.11.4 \ unicode_names2@git+https://github.com/youknowone/unicode_names2.git?rev=4ce16aa85cbcdd9cc830410f1a72ef9a235f2fde\#4ce16aa85cbcdd9cc830410f1a72ef9a235f2fde \ opentelemetry,opentelemetry-proto,opentelemetry_sdk@git+https://github.com/waynexia/opentelemetry-rust.git?rev=33841b38dda79b15f2024952be5f32533325ca02\#33841b38dda79b15f2024952be5f32533325ca02 +USER= nobody +GROUP= nobody + +SUB_LIST+= USER=${USER} GROUP=${GROUP} +PLIST_SUB+= USER=${USER} GROUP=${GROUP} + PROGS= greptime \ nyc-taxi \ sqlness-runner -PLIST_FILES= ${PROGS:S/^/bin\//} - -BINARY_ALIAS= git=false - do-install: - # workaround for error: found a virtual manifest at `xx` instead of a package manifest + # binaries (workaround for error: found a virtual manifest at `xx` instead of a package manifest) .for p in ${PROGS} ${INSTALL_PROGRAM} \ ${WRKDIR}/target/*/release/${p} \ ${STAGEDIR}${PREFIX}/bin .endfor + # config files + ${MKDIR} ${STAGEDIR}${ETCDIR} +.for name in datanode frontend metasrv standalone + ${INSTALL_DATA} ${WRKSRC}/config/${name}.example.toml ${STAGEDIR}${ETCDIR}/${name}.toml.sample +.endfor + ${REINPLACE_CMD} -i '' -e 's|data_home = "/tmp/greptimedb/"|data_home = "/var/db/greptimedb/"|' ${STAGEDIR}${ETCDIR}/*.toml.sample + # RC script + ${INSTALL_DATA} ${WRKDIR}/greptimedb ${STAGEDIR}/${PREFIX}/etc/rc.d + # create dirs + ${MKDIR} \ + ${STAGEDIR}/var/db/greptimedb \ + ${STAGEDIR}/var/log/greptimedb .include diff --git a/databases/greptimedb/files/greptimedb.in b/databases/greptimedb/files/greptimedb.in new file mode 100644 index 000000000000..5fe613368e2d --- /dev/null +++ b/databases/greptimedb/files/greptimedb.in @@ -0,0 +1,126 @@ +#!/bin/sh + +# PROVIDE: greptimedb +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf to run greptimedb: +# +# greptimedb_profiles (str): Set to "" by default. +# Define your profiles here. +# greptimedb(_profile)?_enable (bool): Set it to "YES" to enable greptimedb. +# Default is "NO". +# greptimedb(_profile)?_args (flags): Set extra args here. More options in greptimedb(1) +# Default is "--log-dir=/var/log/greptimedb --log-level=info \ +# standalone start -c %%ETCDIR%%/standalone.toml" +# for the 'standalone' mode. +# greptimedb(_profile)?_user (user): Set user to run greptimedb. +# Default is "nobody". +# greptimedb(_profile)?_group (group): Set group to run greptimedb. +# Default is "nobody". +# greptimedb(_profile)?_post_start (str): Set extra commands that should be executed after greptimedb was successfully +# started here. +# Default is empty "". + +. /etc/rc.subr + +name="greptimedb" +rcvar=greptimedb_enable + +_piddir="/var/run/greptimedb" +pidfile="${_piddir}/greptimedb.pid" + +: ${greptimedb_enable="NO"} +: ${greptimedb_user="%%USER%%"} +: ${greptimedb_group="%%GROUP%%"} +: ${greptimedb_args="--log-dir=/var/log/greptimedb --log-level=info standalone start -c %%ETCDIR%%/standalone.toml"} # standalone mode + +load_rc_config ${name} + +if [ -n "$2" ]; then # profile is provided + profile="$2" + if [ -n "${greptimedb_profiles}" ]; then + pidfile="${_piddir}/greptimedb.${profile}.pid" + eval greptimedb_enable="\${greptimedb_${profile}_enable:-${greptimedb_enable}}" + eval greptimedb_user="\${greptimedb_${profile}_user:-${greptimedb_user}}" + eval greptimedb_group="\${greptimedb_${profile}_group:-${greptimedb_group}}" + eval greptimedb_args="\${greptimedb_${profile}_args:-${greptimedb_args}}" + eval greptimedb_post_start="\${greptimedb_${profile}_post_start:-${greptimedb_post_start}}" + else + echo "%%PREFIX%%/etc/rc.d/greptimedb: extra argument ignored" + fi +else # profile is not provided + if [ -n "${greptimedb_profiles}" -a -n "$1" ]; then + for profile in ${greptimedb_profiles}; do + eval _enable="\${greptimedb_${profile}_enable}" + case "${_enable:-${greptimedb_enable}}" in + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + continue + ;; + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + ;; + *) + if test -z "$_enable"; then + _var=greptimedb_enable + else + _var=greptimedb_"${profile}"_enable + fi + warn "Bad value" \ + "'${_enable:-${greptimedb_enable}}'" \ + "for ${_var}. " \ + "Profile ${profile} skipped." + continue + ;; + esac + echo "===> greptimedb profile: ${profile}" + if %%PREFIX%%/etc/rc.d/greptimedb $1 ${profile} ; then + success="${profile} ${success:-}" + else + failed="${profile} (${retcode}) ${failed:-}" + fi + done + exit 0 + fi +fi + +greptimedb_poststart() +{ + if [ -n "$greptimedb_post_start" ]; then + eval $greptimedb_post_start + fi +} + +greptimedb_poststop() +{ + if [ -n "${profile}" ]; then + [ -e "$pidfile" ] && unlink $pidfile + else + local file + + for file in ${_piddir}/* ; do + case "$file" in + *\*) + continue ;; + esac + unlink $file + done + fi +} + +_profsuffx="" +if [ -n "${profile}" ]; then + _profsuffx="-${profile}" +fi + +procname=%%PREFIX%%/bin/greptime +command="/usr/sbin/daemon" +command_args="-f -S -p ${pidfile} \ + -t greptimedb${_profsuffx} \ + %%PREFIX%%/bin/greptime $greptimedb_args" + + +start_precmd="install -d -o $greptimedb_user -g $greptimedb_group -m 755 $_piddir" +start_postcmd="${name}_poststart" +stop_postcmd="${name}_poststop" + +run_rc_command "$1" diff --git a/databases/greptimedb/pkg-plist b/databases/greptimedb/pkg-plist new file mode 100644 index 000000000000..1f2e39d2b8b0 --- /dev/null +++ b/databases/greptimedb/pkg-plist @@ -0,0 +1,9 @@ +bin/greptime +bin/nyc-taxi +bin/sqlness-runner +@sample %%ETCDIR%%/datanode.toml.sample +@sample %%ETCDIR%%/frontend.toml.sample +@sample %%ETCDIR%%/metasrv.toml.sample +@sample %%ETCDIR%%/standalone.toml.sample +@dir(%%USER%%,%%GROUP%%,) /var/db/greptimedb +@dir(%%USER%%,%%GROUP%%,) /var/log/greptimedb