git: edc99c24c3c0 - main - sysutils/digdag: Improve startup script

From: Emanuel Haupt <ehaupt_at_FreeBSD.org>
Date: Wed, 19 Jan 2022 22:19:18 UTC
The branch main has been updated by ehaupt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=edc99c24c3c089289441f281c36e12861c437abc

commit edc99c24c3c089289441f281c36e12861c437abc
Author:     Emanuel Haupt <ehaupt@FreeBSD.org>
AuthorDate: 2022-01-19 22:19:04 +0000
Commit:     Emanuel Haupt <ehaupt@FreeBSD.org>
CommitDate: 2022-01-19 22:19:04 +0000

    sysutils/digdag: Improve startup script
    
    Improve startup script to provide a better user experience. The default
    configuration provides a typical minimal ready-to-go setup.
    
    While here pacify portclippy and portfmt.
---
 sysutils/digdag/Makefile                 | 20 ++++++++++----------
 sysutils/digdag/files/digdag.conf.sample |  1 +
 sysutils/digdag/files/digdag.in          | 23 +++++++++++++++++++++--
 sysutils/digdag/pkg-plist                |  1 -
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/sysutils/digdag/Makefile b/sysutils/digdag/Makefile
index 498caeb40770..f26ad65d7833 100644
--- a/sysutils/digdag/Makefile
+++ b/sysutils/digdag/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	digdag
 DISTVERSION=	0.10.4
+PORTREVISION=	1
 CATEGORIES=	sysutils java
 MASTER_SITES=	https://github.com/treasure-data/digdag/releases/download/v${DISTVERSION}/ \
 		LOCAL/ehaupt
@@ -13,21 +14,21 @@ COMMENT=	Workload Automation System
 LICENSE=	APACHE20
 
 USE_JAVA=	yes
-USE_RC_SUBR=	${PORTNAME}
-
-JAVA_RUN=	yes
-JAVA_VENDOR=	openjdk
 JAVA_VERSION=	1.8+
+JAVA_VENDOR=	openjdk
+JAVA_RUN=	yes
+USE_RC_SUBR=	${PORTNAME}
 
-NO_BUILD=	yes
 NO_ARCH=	yes
+NO_BUILD=	yes
 
+SUB_LIST=	JAVA=${JAVA} \
+		PORTNAME=${PORTNAME} \
+		USERS=${USERS}
 USERS=		digdag
+PLIST_SUB=	USERS=${USERS} \
+		VERSION=${DISTVERSION}
 
-SUB_LIST=	PORTNAME=${PORTNAME} USERS=${USERS} JAVA=${JAVA}
-PLIST_SUB=	VERSION=${DISTVERSION} USERS=${USERS}
-
-VARLOG=		/var/log/${PORTNAME}
 VARRUN=		/var/run/${PORTNAME}
 
 do-extract:
@@ -44,7 +45,6 @@ do-install:
 	${INSTALL_DATA} ${FILESDIR}/${PORTNAME}.conf.sample \
 		${STAGEDIR}${PREFIX}/etc
 
-	@${MKDIR} ${STAGEDIR}${VARLOG}
 	@${MKDIR} ${STAGEDIR}${VARRUN}
 
 cklatest:
diff --git a/sysutils/digdag/files/digdag.conf.sample b/sysutils/digdag/files/digdag.conf.sample
index b372d58c6660..49f9496b15d7 100644
--- a/sysutils/digdag/files/digdag.conf.sample
+++ b/sysutils/digdag/files/digdag.conf.sample
@@ -50,6 +50,7 @@
 #api.max_sessions_page_size (integer. The max number of rows of sessions in api response)
 
 server.bind=127.0.0.1
+database.type=h2
 # generate with:
 #  openssl rand -base64 16
 #digdag.secret-encryption-key=<base64 key>
diff --git a/sysutils/digdag/files/digdag.in b/sysutils/digdag/files/digdag.in
index b1fc365a22f8..e5e5498ed4a5 100644
--- a/sysutils/digdag/files/digdag.in
+++ b/sysutils/digdag/files/digdag.in
@@ -25,11 +25,30 @@ load_rc_config ${name}
 : ${digdag_enable:="NO"}
 : ${digdag_user:="digdag"}
 : ${digdag_conf:="%%PREFIX%%/etc/digdag.conf"}
-: ${digdag_logfile="/var/log/digdag/digdag.log"}
+: ${digdag_logdir:="/var/log/digdag"}
+: ${digdag_logfile:="${digdag_logdir}/digdag.log"}
+: ${digdag_taskdir:="${digdag_logdir}/tasks"}
+: ${digdag_dbdir:="/var/db/digdag"}
 
 command="/usr/sbin/daemon"
 pidfile=/var/run/digdag/digdag.pid
 procname="%%JAVA%%"
-digdag_flags="-f -p ${pidfile} ${name} server --log ${digdag_logfile} --config ${digdag_conf}"
+digdag_flags="-f -p ${pidfile} ${name} server --log ${digdag_logfile} --task-log ${digdag_taskdir} --database ${digdag_dbdir} --config ${digdag_conf}"
+
+start_precmd="digdag_prestart"
+
+digdag_prestart()
+{
+	for dir in ${digdag_logdir} ${digdag_taskdir}
+	do
+		if [ ! -d ${dir} ]; then
+			install -d -m 0755 -o ${digdag_user} ${dir}
+		fi
+	done
+
+	if [ ! -d ${digdag_dbdir} ]; then
+		install -d -m 0750 -o ${digdag_user} ${digdag_dbdir}
+	fi
+}
 
 run_rc_command "$1"
diff --git a/sysutils/digdag/pkg-plist b/sysutils/digdag/pkg-plist
index d7a4da5f3de4..db2a9c8d27d6 100644
--- a/sysutils/digdag/pkg-plist
+++ b/sysutils/digdag/pkg-plist
@@ -2,5 +2,4 @@
 %%JAVAJARDIR%%/digdag/digdag-%%VERSION%%.jar
 bin/digdag
 @owner %%USERS%%
-@dir /var/log/digdag
 @dir /var/run/digdag