diff --git a/sysutils/slurm-wlm/Makefile b/sysutils/slurm-wlm/Makefile index 9dcd334a93d1..dab07c1d9a1c 100644 --- a/sysutils/slurm-wlm/Makefile +++ b/sysutils/slurm-wlm/Makefile @@ -1,134 +1,135 @@ PORTNAME= slurm DISTVERSION= 25.11.0 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= https://download.schedmd.com/slurm/ PKGNAMESUFFIX= -wlm MAINTAINER= rikka.goering@outlook.de COMMENT= Simple Linux Utility for Resource Management WWW= https://slurm.schedmd.com/ LICENSE= GPLv2+ LICENSE_FILE= ${WRKSRC}/COPYING NOT_FOR_ARCHS= armv6 armv7 i386 mips powerpc powerpcspe NOT_FOR_ARCHS_REASON= 32-bit support is deprecated LIB_DEPENDS= libhttp_parser.so:www/http-parser \ libjson-c.so:devel/json-c \ libjwt.so:www/libjwt \ liblz4.so:archivers/liblz4 \ libmunge.so:security/munge \ librdkafka.so:net/librdkafka \ libsysinfo.so:devel/libsysinfo \ libunwind.so:devel/libunwind \ libyaml.so:textproc/libyaml USES= compiler:c11 cpe gmake libtool localbase lua mysql:client perl5 \ pkgconfig python:build readline shebangfix ssl tar:bz2 CPE_VENDOR= schedmd USE_LDCONFIG= yes USE_PERL5= build USE_RC_SUBR= slurmctld slurmd SHEBANG_FILES= doc/html/shtml2html.py doc/man/man2html.py GNU_CONFIGURE= yes # FreeBSD Infiniband support is still experimental # slurmrestd does not build on FreeBSD CONFIGURE_ARGS= --disable-dependency-tracking \ --disable-slurmrestd \ --docdir=${DOCSDIR} \ --htmldir=${DOCSDIR} \ --sysconfdir=${ETCDIR} \ --with-mysql_config=${LOCALBASE}/bin CONFIGURE_ENV= MAKE=${GMAKE} INSTALL_TARGET= install-strip TEST_TARGET= check CFLAGS+= -I${WRKSRC}/slurm LDFLAGS+= -lsysinfo -lprocstat -fcommon SUB_FILES= pkg-message USERS= ${PORTNAME} GROUPS= ${PORTNAME} PLIST_SUB= GROUPS=${GROUPS} \ USERS=${USERS} PORTDOCS= * OPTIONS_DEFINE= CURL DOCS GUI HDF5 HWLOC IPMI OPTIONS_DEFAULT= HDF5 HWLOC OPTIONS_SUB= yes CURL_DESC= Require cURL for elasticsearch plugins GUI_DESC= Build sview GUI config tool HDF5_DESC= Job profiling using HDF5 HWLOC_DESC= Portable hardware locality IPMI_DESC= IPMI energy consumption accounting CURL_LIB_DEPENDS= libcurl.so:ftp/curl CURL_CONFIGURE_WITH= libcurl DOCS_BUILD_DEPENDS= man2html:textproc/man2html GUI_BUILD_DEPENDS= itstool:textproc/itstool GUI_USES= gnome GUI_USE= GNOME=cairo,gdkpixbuf,glib20,gtk20,pango GUI_CONFIGURE_ENABLE= glibtest gtktest x11 HDF5_LIB_DEPENDS= libhdf5.so:science/hdf5 \ libhdf5_hl.so:science/hdf5 HDF5_CONFIGURE_WITH= hdf5 HDF5_CONFIGURE_ENV= H5CC=${LOCALBASE}/bin/h5cc \ H5FC=${LOCALBASE}/bin/h5fc HDF5_LDFLAGS= -lhdf5_hl HWLOC_LIB_DEPENDS= libhwloc.so.15:devel/hwloc2 HWLOC_CONFIGURE_WITH= hwloc IPMI_LIB_DEPENDS= libfreeipmi.so:sysutils/freeipmi \ libipmimonitoring.so:sysutils/freeipmi IPMI_CONFIGURE_WITH= freeipmi _ARCH= ${ARCH:S|aarch64|aarch64elf|:S|amd64|elf_amd64|:S|powerpc64|elf64ppc|:S|powerpc64le|elf64lppc|:S|riscv64|elf64lriscv|} # SLURM's configure enables interactive jobs if pty.h exists. Replacing # #include with appropriate headers will therefore not work, so instead # add a pty.h for the build. pre-configure: ${CP} ${FILESDIR}/pty.h ${WRKSRC}/slurm ${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|' ${WRKSRC}/configure # Make /proc => /compat/linux/proc edits only in files that exist & contain "/proc" (cd ${WRKSRC} && \ ${GREP} -RIl '"/proc' src | ${XARGS} ${REINPLACE_CMD} \ -e 's|"/proc|"/compat/linux/proc|g' \ -e 's|(/proc)|(/compat/linux/proc)|g') @if ${WHICH} sbatch > /dev/null; then \ ${ECHO_CMD} "********************************************"; \ ${ECHO_CMD} "Build may fail while slurm-wlm is installed."; \ ${ECHO_CMD} "Deinstall slurm-wlm and run make again."; \ ${ECHO_CMD} "********************************************"; \ false; \ fi # Fix lld binary-blob rule: add -m ${_ARCH} wherever --format=binary is used ${FIND} ${WRKSRC} -name Makefile.in -print0 | \ ${XARGS} -0 ${GREP} -Il -- '--format=binary' | \ ${XARGS} ${REINPLACE_CMD} -e 's|$$(LD) -r -o|$$(LD) -r -m ${_ARCH} -o|' ${FIND} ${WRKSRC} -name Makefile.in | ${XARGS} \ ${REINPLACE_CMD} -e 's|htmldir = \$${datadir.*$$|htmldir = @htmldir@|' # Hack around nonfunctional --disable-gtktest flag pre-configure-GUI-off: ${REINPLACE_CMD} -e 's|min_gtk_version=.*|min_gtk_version=2000.0.0|' \ ${WRKSRC}/configure post-install: @${MKDIR} ${STAGEDIR}/var/spool/slurmctld \ ${STAGEDIR}${ETCDIR} ${INSTALL_DATA} ${WRKSRC}/etc/slurm.conf.example \ ${STAGEDIR}${ETCDIR}/slurm.conf.sample .include diff --git a/sysutils/slurm-wlm/files/slurmctld.in b/sysutils/slurm-wlm/files/slurmctld.in index 5199e48b23bc..94f5429687d4 100644 --- a/sysutils/slurm-wlm/files/slurmctld.in +++ b/sysutils/slurm-wlm/files/slurmctld.in @@ -1,43 +1,140 @@ #!/bin/sh # PROVIDE: slurmctld # REQUIRE: DAEMON munge # BEFORE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # -# slurmctld_enable (bool): Set to NO by default. -# Set it to YES to enable slurmctld. +# slurmctld_enable (bool): Set to NO by default. +# Set it to YES to enable slurmctld. +# +# Common knobs (honoured by slurmctld and slurmd): +# slurm_user (str): User to run Slurm daemons as (default: slurm) +# slurm_group (str): Group to run Slurm daemons as (default: slurm) +# slurm_conf (str): Path to slurm.conf, exported as SLURM_CONF +# (default: %%ETCDIR%%/slurm.conf) +# slurm_logdir (str): Log directory (default: /var/log/slurm) +# slurm_rundir (str): Runtime directory (default: /var/run/slurm) +# +# Service-specific knobs: +# slurmctld_flags (str): Extra arguments passed to slurmctld. +# slurmctld_pidfile (str): PID file path +# (default: ${slurm_rundir}/slurmctld.pid) +# slurmctld_logfile (str): Log file path +# (default: ${slurm_logdir}/slurmctld.log) # . /etc/rc.subr name="slurmctld" -rcvar=slurmctld_enable - -pidfile=/var/run/$name.pid +rcvar="slurmctld_enable" load_rc_config $name -: ${slurmctld_enable="NO"} +# Common defaults (shared conceptual contract with slurmd) +: ${slurm_user:="slurm"} +: ${slurm_group:="slurm"} +: ${slurm_conf:="%%ETCDIR%%/slurm.conf"} +: ${slurm_logdir:="/var/log/slurm"} +: ${slurm_rundir:="/var/run/slurm"} + +# Service defaults +: ${slurmctld_enable:="NO"} +: ${slurmctld_flags:=""} +: ${slurmctld_pidfile:="${slurm_rundir}/slurmctld.pid"} +: ${slurmctld_logfile:="${slurm_logdir}/slurmctld.log"} + +pidfile="${slurmctld_pidfile}" -start_cmd=slurmctld_start -stop_cmd=slurmctld_stop +# We run slurmctld under daemon(8) for pidfile/log management. +command="/usr/sbin/daemon" +procname="%%PREFIX%%/sbin/${name}" +command_args="-P ${pidfile} -o ${slurmctld_logfile} ${procname} -D ${slurmctld_flags}" + +extra_commands="reload" +start_precmd="${name}_prestart" +reload_cmd="${name}_reload" +status_cmd="${name}_status" +stop_cmd="${name}_stop" + +slurmctld_prestart() +{ + # Ensure log and run directories exist with correct ownership/modes. + /usr/bin/install -d -o "${slurm_user}" -g "${slurm_group}" -m 0750 "${slurm_logdir}" || return 1 + /usr/bin/install -d -o "root" -g "wheel" -m 0755 "${slurm_rundir}" || return 1 + + # Export SLURM_CONF if not already provided in the environment. + if [ -z "${SLURM_CONF}" ]; then + export SLURM_CONF="${slurm_conf}" + fi +} -slurmctld_start() { - checkyesno slurmctld_enable && echo "Starting $name." && \ - %%PREFIX%%/sbin/$name $slurmctld_flags +slurmctld_reload() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} not running? (pidfile not found)" + return 1 + fi + echo "Reloading ${name} configuration." + kill -HUP "$(cat "${pidfile}")" } -slurmctld_stop() { - if [ -e $pidfile ]; then - checkyesno slurmctld_enable && echo "Stopping $name." && \ - kill `cat $pidfile` - else - killall $name - fi +slurmctld_status() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} is not running (no pidfile)." + return 1 + fi + if ! check_pidfile "${pidfile}" "${procname}"; then + echo "${name} is not running (stale pidfile)." + return 1 + fi + echo "${name} is running as pid $(cat "${pidfile}")." +} + +slurmctld_stop() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} not running? (no pidfile)." + return 1 + fi + + if ! check_pidfile "${pidfile}" "${procname}"; then + echo "${name} not running? (stale pidfile: ${pidfile})." + rm -f "${pidfile}" + return 1 + fi + + pid="$(cat "${pidfile}" 2>/dev/null || true)" + if [ -z "${pid}" ]; then + echo "${name} not running? (empty pidfile: ${pidfile})." + rm -f "${pidfile}" + return 1 + fi + + echo "Stopping ${name} (pid ${pid})." + kill -TERM "${pid}" 2>/dev/null || true + + # Allow a short grace period for clean shutdown and helper cleanup. + i=0 + while [ $i -lt 5 ]; do + if ! check_pidfile "${pidfile}" "${procname}"; then + rm -f "${pidfile}" + return 0 + fi + i=$((i + 1)) + sleep 1 + done + + echo "${name} did not exit on SIGTERM; sending SIGKILL to controller and its helpers." + # Kill children (e.g. slurmscriptd) first, then the controller itself. + pkill -KILL -P "${pid}" 2>/dev/null || true + kill -KILL "${pid}" 2>/dev/null || true + + rm -f "${pidfile}" } run_rc_command "$1" diff --git a/sysutils/slurm-wlm/files/slurmd.in b/sysutils/slurm-wlm/files/slurmd.in index 277d48a2d317..462cbc6611a0 100644 --- a/sysutils/slurm-wlm/files/slurmd.in +++ b/sysutils/slurm-wlm/files/slurmd.in @@ -1,43 +1,118 @@ #!/bin/sh # PROVIDE: slurmd # REQUIRE: DAEMON munge # BEFORE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # -# slurmd_enable (bool): Set to NO by default. -# Set it to YES to enable slurmd. +# slurmd_enable (bool): Set to NO by default. +# Set it to YES to enable slurmd. +# +# Common knobs (honoured by slurmd and slurmctld): +# slurm_user (str): User to run Slurm daemons as (default: slurm) +# slurm_group (str): Group to run Slurm daemons as (default: slurm) +# slurm_conf (str): Path to slurm.conf, exported as SLURM_CONF +# (default: %%ETCDIR%%/slurm.conf) +# slurm_logdir (str): Log directory (default: /var/log/slurm) +# slurm_rundir (str): Runtime directory (default: /var/run/slurm) +# +# Service-specific knobs: +# slurmd_flags (str): Extra arguments passed to slurmd. +# slurmd_pidfile (str): PID file path +# (default: ${slurm_rundir}/slurmd.pid) +# slurmd_logfile (str): Log file path +# (default: ${slurm_logdir}/slurmd.log) # . /etc/rc.subr name="slurmd" -rcvar=slurmd_enable - -pidfile=/var/run/$name.pid +rcvar="slurmd_enable" load_rc_config $name -: ${slurmd_enable="NO"} +# Common defaults (shared conceptual contract with slurmctld) +: ${slurm_user:="slurm"} +: ${slurm_group:="slurm"} +: ${slurm_conf:="%%ETCDIR%%/slurm.conf"} +: ${slurm_logdir:="/var/log/slurm"} +: ${slurm_rundir:="/var/run/slurm"} + +# Service defaults +: ${slurmd_enable:="NO"} +: ${slurmd_flags:=""} +: ${slurmd_pidfile:="${slurm_rundir}/slurmd.pid"} +: ${slurmd_logfile:="${slurm_logdir}/slurmd.log"} + +pidfile="${slurmd_pidfile}" + +command="/usr/sbin/daemon" +procname="%%PREFIX%%/sbin/${name}" +command_args="-P ${pidfile} -o ${slurmd_logfile} ${procname} -D ${slurmd_flags}" + +extra_commands="reload" +start_precmd="${name}_prestart" +reload_cmd="${name}_reload" +status_cmd="${name}_status" +stop_cmd="${name}_stop" -start_cmd=slurmd_start -stop_cmd=slurmd_stop +slurmd_prestart() +{ + # Ensure log and run directories exist with correct ownership/modes. + /usr/bin/install -d -o "${slurm_user}" -g "${slurm_group}" -m 0750 "${slurm_logdir}" || return 1 + /usr/bin/install -d -o "root" -g "wheel" -m 0755 "${slurm_rundir}" || return 1 -slurmd_start() { - checkyesno slurmd_enable && echo "Starting $name." && \ - %%PREFIX%%/sbin/$name $slurmd_flags + # Export SLURM_CONF if not already provided in the environment. + if [ -z "${SLURM_CONF}" ]; then + export SLURM_CONF="${slurm_conf}" + fi } -slurmd_stop() { - if [ -e $pidfile ]; then - checkyesno slurmd_enable && echo "Stopping $name." && \ - kill `cat $pidfile` - else - killall $name - fi +slurmd_reload() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} not running? (pidfile not found)" + return 1 + fi + echo "Reloading ${name} configuration." + kill -HUP "$(cat "${pidfile}")" +} + +slurmd_status() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} is not running (no pidfile)." + return 1 + fi + if ! check_pidfile "${pidfile}" "${procname}"; then + echo "${name} is not running (stale pidfile)." + return 1 + fi + echo "${name} is running as pid $(cat "${pidfile}")." +} + +slurmd_stop() +{ + if [ ! -r "${pidfile}" ]; then + echo "${name} not running? (no pidfile)." + return 1 + fi + + if ! check_pidfile "${pidfile}" "${procname}"; then + echo "${name} not running? (stale pidfile: ${pidfile})." + rm -f "${pidfile}" + return 1 + fi + + echo "Stopping ${name}." + kill -TERM "$(cat "${pidfile}")" 2>/dev/null || true + + if check_pidfile "${pidfile}" "${procname}"; then + rm -f "${pidfile}" + fi } run_rc_command "$1"