pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
nats-server: Create rc.d and SMF bits
Module Name: pkgsrc-wip
Committed By: Juraj Lutter <otis%NetBSD.org@localhost>
Pushed By: otis
Date: Mon Oct 12 15:36:32 2020 +0000
Changeset: 2d7beee4df74e3b9f4b6919e6d54eafd34eca129
Modified Files:
nats-server/Makefile
Added Files:
nats-server/files/nats-server.sh
nats-server/files/smf/manifest.xml
nats-server/files/smf/nats-server.sh
Log Message:
nats-server: Create rc.d and SMF bits
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=2d7beee4df74e3b9f4b6919e6d54eafd34eca129
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
nats-server/Makefile | 29 +++++++++++++++
nats-server/files/nats-server.sh | 68 ++++++++++++++++++++++++++++++++++++
nats-server/files/smf/manifest.xml | 32 +++++++++++++++++
nats-server/files/smf/nats-server.sh | 29 +++++++++++++++
4 files changed, 158 insertions(+)
diffs:
diff --git a/nats-server/Makefile b/nats-server/Makefile
index 52a742a737..accd2b42d1 100644
--- a/nats-server/Makefile
+++ b/nats-server/Makefile
@@ -12,7 +12,36 @@ LICENSE= apache-2.0
GO_BUILD_PATTERN= .
+NATS_USER= natssrv
+NATS_GROUP= natssrv
+NATS_HOMEDIR= ${VARBASE}/nats-server
+NATS_LOGDIR= ${VARBASE}/log/nats-server
+NATS_LOGFILE= ${NATS_LOGDIR}/nats-server.log
+
+CHECK_SSP_SKIP= bin/*
+
.include "go-modules.mk"
+.include "../../mk/bsd.prefs.mk"
+
+PKG_GROUPS= ${NATS_GROUP}
+PKG_USERS= ${NATS_USER}:${NATS_GROUP}
+
+PKG_HOME.${NATS_USER}= ${NATS_HOMEDIR}
+PKG_GECOS.${NATS_USER}= nats.io server
+
+RCD_SCRIPTS= nats-server
+SMF_NAME= nats-server
+SMF_METHODS= ${RCD_SCRIPTS}
+
+FILES_SUBST+= NATS_USER=${NATS_USER}
+FILES_SUBST+= NATS_GROUP=${NATS_GROUP}
+FILES_SUBST+= NATS_HOMEDIR=${NATS_HOMEDIR}
+FILES_SUBST+= NATS_LOGDIR=${NATS_LOGDIR}
+FILES_SUBST+= NATS_LOGFILE=${NATS_LOGFILE}
+
+OWN_DIRS_PERMS+= ${NATS_HOMEDIR} ${NATS_USER} ${NATS_GROUP} 0700
+MAKE_DIRS_PERMS+= ${NATS_LOGDIR} ${NATS_USER} ${NATS_GROUP} 0700
+
.include "../../lang/go/go-module.mk"
.include "../../mk/bsd.pkg.mk"
diff --git a/nats-server/files/nats-server.sh b/nats-server/files/nats-server.sh
new file mode 100644
index 0000000000..e41da3c114
--- /dev/null
+++ b/nats-server/files/nats-server.sh
@@ -0,0 +1,68 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD$
+#
+# PROVIDE: nats-server
+# REQUIRE: DAEMON LOGIN mountall
+# KEYWORD: shutdown
+#
+# You will need to set some variables in /etc/rc.conf to start nats-server:
+#
+# natsserver=YES
+#
+# The following variables are optional:
+#
+# natsserver_pidfile="/path/to/p.pid" path to nats-server PID file
+# default:
+# @NATS_HOMEDIR@/nats-server.pid
+# natsserver_logfile="/path/to/p.log" path to nats-server log file
+# default:
+# @NATS_LOGFILE@
+# natsserver_user="natssrv" the username for nats-server daemon
+# natsserver_group="natssrv" the group for nats-server daemon
+
+if [ -f /etc/rc.subr ]; then
+ . /etc/rc.subr
+fi
+
+name="nats-server"
+rcvar="natsserver"
+command="@PREFIX@/bin/nats-server"
+: ${natsserver_pidfile:="@NATS_HOMEDIR@/nats-server.pid"}
+: ${natsserver_logfile:="@NATS_LOGFILE@"}
+: ${natsserver_user:="natssrv"}
+: ${natsserver_group:="natssrv"}
+
+start_cmd="natssrv_start"
+
+natssrv_start()
+{
+ @ECHO@ "Starting ${name}."
+ ulimit -n 4096
+ cd @NATS_HOMEDIR@
+ /usr/bin/su ${natsserver_user}:${natsserver_group} \
+ ${command} -P ${natsserver_pidfile} \
+ -l ${natsserver_logfile} &
+}
+
+if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
+ load_rc_config $name
+ pidfile="${natsserver_pidfile}"
+ run_rc_command "$1"
+else
+ if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+ fi
+ pidfile="${natsserver_pidfile}"
+ case "$1" in
+ stop)
+ if [ -r "${pidfile}" ]; then
+ @ECHO@ "Stopping ${name}."
+ kill `@CAT@ ${pidfile}`
+ fi
+ ;;
+ *)
+ eval ${start_cmd}
+ ;;
+ esac
+fi
diff --git a/nats-server/files/smf/manifest.xml b/nats-server/files/smf/manifest.xml
new file mode 100644
index 0000000000..fbd769eb8b
--- /dev/null
+++ b/nats-server/files/smf/manifest.xml
@@ -0,0 +1,32 @@
+<?xml version='1.0'?>
+<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
+<service_bundle type='manifest' name='@SMF_NAME@'>
+ <service name='@SMF_PREFIX@/@SMF_NAME@' type='service' version='1'>
+ <create_default_instance enabled='false' />
+ <single_instance />
+ <dependency name='fs' grouping='require_all' restart_on='none' type='service'>
+ <service_fmri value='svc:/system/filesystem/local' />
+ </dependency>
+ <dependency name='net' grouping='require_all' restart_on='none' type='service'>
+ <service_fmri value='svc:/network/loopback' />
+ </dependency>
+ <method_context working_directory='@VARBASE@/nats-server'>
+ <method_credential user='@NATS_USER@' group='@NATS_GROUP@' />
+ <method_environment>
+ <envvar name='LD_PRELOAD_32' value='/usr/lib/extendedFILE.so.1' />
+ </method_environment>
+ </method_context>
+ <exec_method name='start' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.nats-server@ start' timeout_seconds='0' />
+ <exec_method name='stop' type='method' exec='@PREFIX@/@SMF_METHOD_FILE.nats-server@ stop' timeout_seconds='0' />
+ <stability value='Evolving' />
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>nats.io messaging server</loctext>
+ </common_name>
+ <documentation>
+ <manpage title='NATS' section='1' />
+ <doc_link name='nats.io' uri='https://nats.io/' />
+ </documentation>
+ </template>
+ </service>
+</service_bundle>
diff --git a/nats-server/files/smf/nats-server.sh b/nats-server/files/smf/nats-server.sh
new file mode 100644
index 0000000000..f3775f5fd7
--- /dev/null
+++ b/nats-server/files/smf/nats-server.sh
@@ -0,0 +1,29 @@
+#!@SMF_METHOD_SHELL@
+#
+# $NetBSD$
+#
+# Init script for nats-server
+#
+
+. /lib/svc/share/smf_include.sh
+
+PIDFILE="@NATS_HOMEDIR@/nats-server.pid"
+LOGFILE="@NATS_LOGFILE@"
+
+ulimit -n 10240
+
+case "$1" in
+start)
+ @PREFIX@/bin/nats-server -P ${PIDFILE} \
+ -l ${LOGFILE} &
+ ;;
+stop)
+ [ -f ${PIDFILE} ] && kill `@HEAD@ -1 ${PIDFILE}`
+ ;;
+*)
+ echo "Usage: $0 {start|stop}" >&2
+ exit 1
+ ;;
+esac
+
+exit $SMF_EXIT_OK
Home |
Main Index |
Thread Index |
Old Index