From owner-svn-ports-all@freebsd.org Thu Feb 18 17:31:59 2016 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21A03AAD44D; Thu, 18 Feb 2016 17:31:59 +0000 (UTC) (envelope-from koobs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D995E990; Thu, 18 Feb 2016 17:31:58 +0000 (UTC) (envelope-from koobs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1IHVvfE048187; Thu, 18 Feb 2016 17:31:57 GMT (envelope-from koobs@FreeBSD.org) Received: (from koobs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1IHVvNE048185; Thu, 18 Feb 2016 17:31:57 GMT (envelope-from koobs@FreeBSD.org) Message-Id: <201602181731.u1IHVvNE048185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: koobs set sender to koobs@FreeBSD.org using -f From: Kubilay Kocak Date: Thu, 18 Feb 2016 17:31:57 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r409121 - in head/devel/buildbot-slave: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2016 17:31:59 -0000 Author: koobs Date: Thu Feb 18 17:31:57 2016 New Revision: 409121 URL: https://svnweb.freebsd.org/changeset/ports/409121 Log: devel/buildbot-slave: Add startup script with profile support Kill a 5+ year old Bugzilla issue [1] by adding a startup script support multiple "profiles" to buildbot-slave. This will save me many 10's of minutes restarting ~15 buildbot builders over 3 VM's manually every time the power goes out, or the Windows host hosting them needs to be restarted :| PR: 152847 [1] Requested by: wollman Added: head/devel/buildbot-slave/files/buildslave.in (contents, props changed) Modified: head/devel/buildbot-slave/Makefile Modified: head/devel/buildbot-slave/Makefile ============================================================================== --- head/devel/buildbot-slave/Makefile Thu Feb 18 17:22:10 2016 (r409120) +++ head/devel/buildbot-slave/Makefile Thu Feb 18 17:31:57 2016 (r409121) @@ -3,7 +3,7 @@ PORTNAME= buildbot-slave PORTVERSION= 0.8.12 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel python MASTER_SITES= CHEESESHOP @@ -19,6 +19,9 @@ TEST_DEPENDS= trial:${PORTSDIR}/devel/py USES= python:-2.7 USE_PYTHON= autoplist distutils +USE_RC_SUBR= buildslave + +SUB_LIST+= PYTHON_CMD=${PYTHON_CMD} NO_ARCH= yes Added: head/devel/buildbot-slave/files/buildslave.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/buildbot-slave/files/buildslave.in Thu Feb 18 17:31:57 2016 (r409121) @@ -0,0 +1,119 @@ +#!/bin/sh + +# $FreeBSD$ +# PROVIDE: buildslave +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Add the following lines to /etc/rc.conf to run buildslave: +# +# buildslave_enable (bool): Set to "YES" to enable buildslave. +# Default: "NO" +# +# buildslave_flags (flags): Set extra command flags here. See buildslave(8) +# Default: Empty (""). +# +# buildslave_uid (user): User to run buildslave as. +# Default: "buildbot" +# +# buildslave_gid (group): Group to run buildslave as. +# Default: "buildbot" +# +# buildslave_basedir (path): Location for buildslave base directory +# Default: %%PREFIX%%/etc/buildslave +# +# buildslave_profiles (str): Define profiles names. Space-delimited. +# Default: Empty ("") +# +# This rc.d script supports multiple "profiles". When profiles are +# specified, the non-profile specific parameters become defaults. +# +# Example: +# +# buildslave_profiles="foo bar" +# +# buildslave_foo_enable="YES" +# buildslave_foo_basedir="/usr/home/foo/buildbot" +# buildslave_foo_uid="foo" +# buildslave_foo_gid="foo" +# +# buildslave_bar_enable="YES" +# buildslave_bar_basedir="/usr/home/buildbot/" + +. /etc/rc.subr + +name=buildslave +desc="Buildbot Buildslave" +rcvar=buildslave_enable + +load_rc_config ${name} + +# These are just the defaults, they might get overriden for a specific profile. +eval ": \${${name}_enable:=\"NO\"}" +eval ": \${${name}_flags:=\"\"}" +eval ": \${${name}_uid:=\"buildbot\"}" +eval ": \${${name}_gid:=\"buildbot\"}" +eval ": \${${name}_basedir:=\"%%PREFIX%%/etc/${name}\"}" + +command="%%PREFIX%%/bin/twistd" +command_interpreter="%%PYTHON_CMD%%" +pidfile="${buildslave_basedir}/twistd.pid" + + # A specific profile is specified in the command + if [ -n "$2" ]; then + profile="$2" + # Override defaults with profile-specific values + if [ -n "${buildslave_profiles}" ]; then + eval buildslave_enable="\${buildslave_${profile}_enable:-${buildslave_enable}}" + eval buildslave_flags="\${buildslave_${profile}_flags:-${buildslave_flags}}" + eval buildslave_uid="\${buildslave_${profile}_uid:-${buildslave_uid}}" + eval buildslave_gid="\${buildslave_${profile}_gid:-${buildslave_gid}}" + eval buildslave_basedir="\${buildslave_${profile}_basedir:-${buildslave_basedir}}" + eval pidfile="\${buildslave_${profile}_basedir:-${buildslave_basedir}}/twistd.pid" + else + echo "%%PREFIX%%/etc/rc.d/${name}: extra argument ignored" + fi + # A specific profile is not in the command + else + # Check if any profiles are defined + if [ -n "$1" -a -n "${buildslave_profiles}" ]; then + # Loop through them + for profile in ${buildslave_profiles}; do + eval _enable="\${buildslave_${profile}_enable}" + case "${_enable:-${buildslave_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=buildslave_enable + else + _var=buildslave_"${profile}"_enable + fi + warn "Bad value" \ + "'${_enable:-${buildslave_enable}}'" \ + "for ${_var}. " \ + "Profile ${profile} skipped." + continue + ;; + esac + echo "===> ${name} profile: ${profile}" + if %%PREFIX%%/etc/rc.d/${name} $1 ${profile}; then + success="${profile} ${success:-}" + else + failed="${profile} (${retcode}) ${failed:-}" + fi + done + # Exit so that non-profile rc.d is not started when there are profiles + exit 0 + fi + fi + +# run_rc_command would send ${name}_flags as parameters to $command (daemon) +# This ensures they are actually passed to fcgiwrap instead. +actual_buildslave_flags="${buildslave_flags}" +buildslave_flags="" +command_args="--uid=${buildslave_uid} --gid=${buildslave_gid} --pidfile=${pidfile} --python=${buildslave_basedir}/buildbot.tac ${actual_buildslave_flags}" +run_rc_command "$1"