Adds RPM specfile and support scripting Bugs closed: AURORA-1116
Reviewed at https://reviews.apache.org/r/33778/ Project: http://git-wip-us.apache.org/repos/asf/aurora-packaging/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora-packaging/commit/df6325c8 Tree: http://git-wip-us.apache.org/repos/asf/aurora-packaging/tree/df6325c8 Diff: http://git-wip-us.apache.org/repos/asf/aurora-packaging/diff/df6325c8 Branch: refs/heads/master Commit: df6325c872c5c6a7b1a01adcad98a940730bcf5e Parents: 6bd5279 Author: Steve Salevan <[email protected]> Authored: Mon Jul 6 14:57:34 2015 -0700 Committer: Bill Farner <[email protected]> Committed: Tue Aug 4 14:07:42 2015 -0700 ---------------------------------------------------------------------- build-support/packaging/rpm/Makefile | 101 ++++++ build-support/packaging/rpm/README.md | 42 +++ build-support/packaging/rpm/aurora.init.sh | 199 +++++++++++ build-support/packaging/rpm/aurora.logrotate | 24 ++ build-support/packaging/rpm/aurora.service | 27 ++ build-support/packaging/rpm/aurora.spec | 344 +++++++++++++++++++ build-support/packaging/rpm/aurora.startup.sh | 27 ++ build-support/packaging/rpm/aurora.sysconfig | 79 +++++ build-support/packaging/rpm/clusters.json | 6 + .../packaging/rpm/thermos-observer.init.sh | 197 +++++++++++ .../packaging/rpm/thermos-observer.logrotate | 24 ++ .../packaging/rpm/thermos-observer.service | 27 ++ .../packaging/rpm/thermos-observer.startup.sh | 19 + .../packaging/rpm/thermos-observer.sysconfig | 22 ++ 14 files changed, 1138 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/Makefile ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/Makefile b/build-support/packaging/rpm/Makefile new file mode 100644 index 0000000..1833a25 --- /dev/null +++ b/build-support/packaging/rpm/Makefile @@ -0,0 +1,101 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +GIT_COMMIT ?= HEAD + +USING_GIT ?= $(shell git status >/dev/null 2>&1 && echo 'true' || echo 'false') +ifeq ($(USING_GIT),true) + VERSION_SUFFIX := .$(shell git rev-parse --short $(GIT_COMMIT)) +else + VERSION_SUFFIX := +endif + +CURRENT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +TOPDIR ?= $(CURRENT_DIR)/../../.. +DIST_DIR ?= $(TOPDIR)/dist +RPM_TOPDIR ?= $(DIST_DIR) + +DATETIME ?= $(shell date +%Y%m%d%H%M) + +SOURCE_TARGET ?= $(RPM_TOPDIR)/rpmbuild/SOURCES/aurora.tar.gz + +AURORA_VERSION ?= $(shell cat $(TOPDIR)/.auroraversion | tr '-' '.') +MESOS_VERSION ?= $(shell sed -n 's/.*mesos\.native==\(.*\)/\1/p' $(TOPDIR)/3rdparty/python/requirements.txt) + + +PHONY: all nightly_version release_version get_source_target clean mkdir srpm nightly_srpm nightly_rpm release_srpm release_rpm tar_source + +all: release_rpm + +nightly_version: + $(eval AURORA_VERSION := $(AURORA_VERSION).$(DATETIME)$(VERSION_SUFFIX)) + +release_version: + $(eval AURORA_VERSION := $(AURORA_VERSION)) + +clean: + rm -rf $(RPM_TOPDIR)/rpmbuild + +mkdir: clean + mkdir -p $(RPM_TOPDIR)/rpmbuild/BUILD + mkdir -p $(RPM_TOPDIR)/rpmbuild/BUILDROOT + mkdir -p $(RPM_TOPDIR)/rpmbuild/RPMS + mkdir -p $(RPM_TOPDIR)/rpmbuild/SOURCES + mkdir -p $(RPM_TOPDIR)/rpmbuild/SRPMS + +tar_source: mkdir + if [[ "$(USING_GIT)" == 'true' ]]; then \ + cd `git rev-parse --show-toplevel` && git archive --format=tar --prefix=aurora/ $(GIT_COMMIT) | gzip > $(SOURCE_TARGET); \ + else \ + tmp_dir=`mktemp -d '/tmp/aurorabuild.XXXXXX'`; \ + mkdir $${tmp_dir}/aurora; \ + cp -r $(TOPDIR)/* $${tmp_dir}/aurora; \ + cd $${tmp_dir}; \ + tar cvzf $(SOURCE_TARGET) aurora; \ + rm -rf $${tmp_dir}; \ + fi + +srpm: tar_source + rpmbuild $(RPM_OPTS) \ + --define "_topdir $(RPM_TOPDIR)" \ + --define "_builddir %{_topdir}/rpmbuild/BUILD" \ + --define "_buildrootdir %{_topdir}/rpmbuild/BUILDROOT" \ + --define "_rpmdir %{_topdir}/rpmbuild/RPMS" \ + --define "_srcrpmdir %{_topdir}/rpmbuild/SRPMS" \ + --define "_specdir %(pwd)" \ + --define "_sourcedir %{_topdir}/rpmbuild/SOURCES" \ + --define "AURORA_VERSION $(AURORA_VERSION)" \ + --define "MESOS_VERSION $(MESOS_VERSION)" \ + --nodeps -bs aurora.spec + +rpm: tar_source + rpmbuild $(RPM_OPTS) \ + --define "_topdir $(RPM_TOPDIR)" \ + --define "_builddir %{_topdir}/rpmbuild/BUILD" \ + --define "_buildrootdir %{_topdir}/rpmbuild/BUILDROOT" \ + --define "_rpmdir %{_topdir}/rpmbuild/RPMS" \ + --define "_srcrpmdir %{_topdir}/rpmbuild/SRPMS" \ + --define "_specdir %(pwd)" \ + --define "_sourcedir %{_topdir}/rpmbuild/SOURCES" \ + --define "AURORA_VERSION $(AURORA_VERSION)" \ + --define "MESOS_VERSION $(MESOS_VERSION)" \ + -ba aurora.spec + +nightly_srpm: nightly_version srpm + +nightly_rpm: nightly_version rpm + +release_srpm: release_version srpm + +release_rpm: release_version rpm http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/README.md ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/README.md b/build-support/packaging/rpm/README.md new file mode 100644 index 0000000..c5916e0 --- /dev/null +++ b/build-support/packaging/rpm/README.md @@ -0,0 +1,42 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +This directory contains all necessary scripting to support the building of Aurora +nightly and release RPMs. Building and deployment have been tested against the following +Red Hat flavors: + + * CentOS 6/7 on x86_64 + * Fedora 19/20 on x86_64 + +How to build using Make and rpmbuild +==================================== + +1. Install the necessary build dependencies via yum-builddep: + +```bash +cd build-support/packaging/rpm +sudo yum install -y make rpm-build yum-utils +make srpm +sudo yum-builddep ../../../dist/rpmbuild/SRPMS/* +``` + +2. Build the RPM via Make. + +```bash +make rpm +``` + +3. After the RPM building process has concluded, RPMs will land here: + +``` +$AURORA_HOME/dist/rpmbuild/RPMS +``` http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.init.sh ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.init.sh b/build-support/packaging/rpm/aurora.init.sh new file mode 100644 index 0000000..ac4c438 --- /dev/null +++ b/build-support/packaging/rpm/aurora.init.sh @@ -0,0 +1,199 @@ +#!/bin/bash +# +# aurora Starts the Aurora task scheduler for Mesos. +# +# chkconfig: 345 55 25 +# description: This script starts the Aurora service scheduler for Apache Mesos, \ +# used for scheduling and executing long-running tasks and \ +# cron jobs. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +### BEGIN INIT INFO +# Provides: aurora +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Starts the Aurora task scheduler for Mesos. +# Description: Starts the Aurora task scheduler for Mesos. +### END INIT INFO + +# Source LSB function library. +. /lib/lsb/init-functions + +aurora_user="aurora" +exec="/usr/bin/aurora-scheduler-startup" +prog="aurora" +logdir="/var/log/aurora" +lockfile="/var/run/aurora.lock" +pid_file="/var/run/aurora.pid" +stderr_log="${logdir}/aurora.log" + +# Get a sane screen width +[ -z "${COLUMNS:-}" ] && COLUMNS=80 +[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype)" + +# Read in init configuration. +if [ -z "${BOOTUP:-}" ]; then + if [ -f /etc/sysconfig/init ]; then + . /etc/sysconfig/init + else + BOOTUP=color + RES_COL=60 + MOVE_TO_COL="echo -en \\033[${RES_COL}G" + SETCOLOR_SUCCESS="echo -en \\033[1;32m" + SETCOLOR_FAILURE="echo -en \\033[1;31m" + SETCOLOR_WARNING="echo -en \\033[1;33m" + SETCOLOR_NORMAL="echo -en \\033[0;39m" + LOGLEVEL=1 + fi + if [ "$CONSOLETYPE" = "serial" ]; then + BOOTUP=serial + MOVE_TO_COL= + SETCOLOR_SUCCESS= + SETCOLOR_FAILURE= + SETCOLOR_WARNING= + SETCOLOR_NORMAL= + fi +fi + +function usage { + err "Starts the Aurora task scheduler for Mesos." + err "Usage: ${0} (restart|start|stop|status)" +} + +function out { + printf '%s\n' "$*"; +} + +function msg { + out "$*" >&2; +} + +function err { + local x=${?}; + msg "$*"; + return $(( ${x} == 0 ? 1 : ${x} )); +} + +function echo_success { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS + echo -n $" OK " + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 0 +} + +function echo_failure { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE + echo -n $"FAILED" + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 1 +} + +# Parse arguments. +ACTION=${1} + +# Ensures that action is. +if [ -z ${ACTION} ]; then + err "ERROR: No action specified." + usage + exit -1 +fi + +start() { + [ -x ${exec} ] || exit 5 + [ -f ${config} ] || exit 6 + echo -n $"Starting $prog: " + start_daemon daemonize -u ${aurora_user} -e ${stderr_log} -p ${pid_file} ${exec} + retval=$? + [ $retval -eq 0 ] && (echo_success; touch $lockfile) || echo_failure + echo + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p ${pid_file} ${exec} + retval=$? + [ $retval -eq 0 ] && (echo_success; rm -f $lockfile) || echo_failure + echo + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + pid=$(pidofproc -p ${pid_file} ${prog}) + if [ $? -eq 0 ]; then + echo "${prog} (pid ${pid}) is running..." + return 0 + else + if [ -e $lockfile ]; then + echo "${prog} dead but lockfile exists" + return 2 + else + echo "${prog} is stopped" + return 1 + fi + fi +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + +# Executes the requested daemon action. +case "${ACTION}" in + start) + rh_status_q && rh_status && exit 0 + start + ;; + stop) + stop + ;; + status) + rh_status + ;; + restart) + restart + ;; + *) + err "ERROR: Invalid action specified." + usage + exit -3 +esac + +exit $? http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.logrotate ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.logrotate b/build-support/packaging/rpm/aurora.logrotate new file mode 100644 index 0000000..1c43073 --- /dev/null +++ b/build-support/packaging/rpm/aurora.logrotate @@ -0,0 +1,24 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +/var/log/aurora/*.log { + + daily + missingok + rotate 14 + compress + delaycompress + notifempty + copytruncate + +} http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.service ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.service b/build-support/packaging/rpm/aurora.service new file mode 100644 index 0000000..b81cb63 --- /dev/null +++ b/build-support/packaging/rpm/aurora.service @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[Unit] +Description=Aurora Scheduler +After=network.target +Wants=network.target + +[Service] +ExecStart=/usr/bin/aurora-scheduler-startup +User=aurora +Group=aurora +Restart=always +RestartSec=20 +LimitNOFILE=16384 + +[Install] +WantedBy=multi-user.target http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.spec ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.spec b/build-support/packaging/rpm/aurora.spec new file mode 100644 index 0000000..d5d5c9f --- /dev/null +++ b/build-support/packaging/rpm/aurora.spec @@ -0,0 +1,344 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Overridable variables; +%if %{?!AURORA_VERSION:1}0 +%global AURORA_VERSION 0.9.0 +%endif + +%if %{?!AURORA_USER:1}0 +%global AURORA_USER aurora +%endif + +%if %{?!AURORA_GROUP:1}0 +%global AURORA_GROUP aurora +%endif + +%if %{?!GRADLE_BASEURL:1}0 +%global GRADLE_BASEURL https://services.gradle.org/distributions +%endif + +%if %{?!GRADLE_VERSION:1}0 +%global GRADLE_VERSION 2.4 +%endif + +%if %{?!JAVA_VERSION:!}0 +%global JAVA_VERSION 1.8.0 +%endif + +%if %{?!MESOS_BASEURL:1}0 +%global MESOS_BASEURL https://archive.apache.org/dist/mesos +%endif + +%if %{?!MESOS_VERSION:1}0 +%global MESOS_VERSION 0.22.0 +%endif + +%if %{?!PEX_BINARIES:1}0 +%global PEX_BINARIES aurora aurora_admin thermos thermos_executor thermos_runner thermos_observer +%endif + +%if %{?!PYTHON_VERSION:1}0 +%global PYTHON_VERSION 2.7 +%endif + + +Name: aurora +Version: %{AURORA_VERSION} +Release: 1%{?dist}.aurora +Summary: A Mesos framework for scheduling and executing long-running services and cron jobs. +Group: Applications/System +License: ASL 2.0 +URL: https://%{name}.apache.org/ + +Source0: https://github.com/apache/%{name}/archive/%{version}/%{name}.tar.gz + +BuildRequires: apr-devel +BuildRequires: cyrus-sasl-devel +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: git +BuildRequires: java-%{JAVA_VERSION}-openjdk-devel +BuildRequires: libcurl-devel +BuildRequires: patch +%if 0%{?rhel} && 0%{?rhel} < 7 +BuildRequires: python27 +BuildRequires: python27-scldevel +%else +BuildRequires: python +BuildRequires: python-devel +%endif +BuildRequires: subversion-devel +BuildRequires: tar +BuildRequires: unzip +BuildRequires: wget +BuildRequires: zlib-devel + +Requires: daemonize +Requires: java-%{JAVA_VERSION}-openjdk +Requires: mesos = %{MESOS_VERSION} + + +%description +Apache Aurora is a service scheduler that runs on top of Mesos, enabling you to schedule +long-running services that take advantage of Mesos' scalability, fault-tolerance, and +resource isolation. + + +%package client +Summary: A client for scheduling services against the Aurora scheduler +Group: Development/Tools + +%if 0%{?rhel} && 0%{?rhel} < 7 +Requires: python27 +%else +Requires: python +%endif + +%description client +A set of command-line applications used for interacting with and administering Aurora +schedulers. + + +%package thermos +Summary: Mesos executor that runs and monitors tasks scheduled by the Aurora scheduler +Group: Applications/System + +Requires: cyrus-sasl +Requires: daemonize +%if 0%{?rhel} && 0%{?rhel} < 7 +Requires: docker-io +%else +Requires: docker +%endif +Requires: mesos = %{MESOS_VERSION} +%if 0%{?rhel} && 0%{?rhel} < 7 +Requires: python27 +%else +Requires: python +%endif + +%description thermos +Thermos a simple process management framework used for orchestrating dependent processes +within a single Mesos chroot. It works in tandem with Aurora to ensure that tasks +scheduled by it are properly executed on Mesos slaves and provides a Web UI to monitor the +state of all running tasks. + + +%prep +%setup -n %{name} + + +%build +# Preferences SCL-installed Python 2.7 if we're building on EL6. +%if 0%{?rhel} && 0%{?rhel} < 7 +export PATH=/opt/rh/python27/root/usr/bin${PATH:+:${PATH}} +export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} +export MANPATH=/opt/rh/python27/root/usr/share/man:${MANPATH} +# For systemtap +export XDG_DATA_DIRS=/opt/rh/python27/root/usr/share${XDG_DATA_DIRS:+:${XDG_DATA_DIRS}} +# For pkg-config +export PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} +%endif + +# Preferences Java 1.8 over any other Java version. +export PATH=/usr/lib/jvm/java-1.8.0/bin:${PATH} + +# Downloads Gradle executable. +wget %{GRADLE_BASEURL}/gradle-%{GRADLE_VERSION}-bin.zip +unzip gradle-%{GRADLE_VERSION}-bin.zip + +# Creates Pants directory where we'll store our native Mesos Python eggs. +mkdir -p .pants.d/python/eggs/ + +# Builds mesos-native and mesos-interface eggs if not currently packaged. +wget "%{MESOS_BASEURL}/%{MESOS_VERSION}/mesos-%{MESOS_VERSION}.tar.gz" +tar xvzf mesos-%{MESOS_VERSION}.tar.gz +pushd mesos-%{MESOS_VERSION} +./configure --disable-java +make +find . -name '*.egg' -exec cp -v {} ../.pants.d/python/eggs/ \; +popd + +# Builds the Aurora scheduler. +./gradle-%{GRADLE_VERSION}/bin/gradle installDist + +# Builds Aurora client PEX binaries. +./pants binary src/main/python/apache/aurora/admin:aurora_admin +./pants binary src/main/python/apache/aurora/client/cli:aurora + +# Builds Aurora Thermos and GC executor PEX binaries. +./pants binary src/main/python/apache/aurora/executor/bin:thermos_executor +./pants binary src/main/python/apache/thermos/cli/bin:thermos +./pants binary src/main/python/apache/thermos/bin:thermos_ckpt +./pants binary src/main/python/apache/thermos/bin:thermos_runner +./pants binary src/main/python/apache/thermos/observer/bin:thermos_observer + +# Packages the Thermos runner within the Thermos executor. +python <<EOF +import contextlib +import zipfile +with contextlib.closing(zipfile.ZipFile('dist/thermos_executor.pex', 'a')) as zf: + zf.writestr('apache/aurora/executor/resources/__init__.py', '') + zf.write('dist/thermos_runner.pex', 'apache/aurora/executor/resources/thermos_runner.pex') +EOF + + +%install +rm -rf $RPM_BUILD_ROOT + +# Builds installation directory structure. +mkdir -p %{buildroot}%{_bindir} +mkdir -p %{buildroot}%{_docdir}/%{name}-%{version} +mkdir -p %{buildroot}%{_prefix}/lib/%{name} +mkdir -p %{buildroot}%{_sharedstatedir} +mkdir -p %{buildroot}%{_localstatedir}/lib/%{name} +mkdir -p %{buildroot}%{_localstatedir}/log/%{name} +mkdir -p %{buildroot}%{_localstatedir}/log/thermos +mkdir -p %{buildroot}%{_localstatedir}/run/thermos +mkdir -p %{buildroot}%{_sysconfdir}/%{name} +mkdir -p %{buildroot}%{_sysconfdir}/init.d +mkdir -p %{buildroot}%{_sysconfdir}/systemd/system +mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d +mkdir -p %{buildroot}%{_sysconfdir}/sysconfig + +# Installs the Aurora scheduler that was just built into /usr/lib/aurora. +cp -r dist/install/aurora-scheduler/* %{buildroot}%{_prefix}/lib/%{name} + +# Installs all PEX binaries. +for pex_binary in %{PEX_BINARIES}; do + install -m 755 dist/${pex_binary}.pex %{buildroot}%{_bindir}/${pex_binary} +done + +# Installs all support scripting. +%if 0%{?fedora} || 0%{?rhel} > 6 +install -m 644 build-support/packaging/rpm/%{name}.service %{buildroot}%{_sysconfdir}/systemd/system/%{name}.service +install -m 644 build-support/packaging/rpm/thermos-observer.service %{buildroot}%{_sysconfdir}/systemd/system/thermos-observer.service +%else +install -m 755 build-support/packaging/rpm/%{name}.init.sh %{buildroot}%{_sysconfdir}/init.d/%{name} +install -m 755 build-support/packaging/rpm/thermos-observer.init.sh %{buildroot}%{_sysconfdir}/init.d/thermos-observer +%endif + +install -m 755 build-support/packaging/rpm/%{name}.startup.sh %{buildroot}%{_bindir}/%{name}-scheduler-startup +install -m 755 build-support/packaging/rpm/thermos-observer.startup.sh %{buildroot}%{_bindir}/thermos-observer-startup + +install -m 644 build-support/packaging/rpm/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name} +install -m 644 build-support/packaging/rpm/thermos-observer.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/thermos-observer + +install -m 644 build-support/packaging/rpm/%{name}.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -m 644 build-support/packaging/rpm/thermos-observer.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/thermos-observer + +install -m 644 build-support/packaging/rpm/clusters.json %{buildroot}%{_sysconfdir}/%{name}/clusters.json + + +%pre +getent group %{AURORA_GROUP} > /dev/null || groupadd -r %{AURORA_GROUP} +getent passwd %{AURORA_USER} > /dev/null || \ + useradd -r -d %{_localstatedir}/lib/%{name} -g %{AURORA_GROUP} \ + -s /bin/bash -c "Aurora Scheduler" %{AURORA_USER} +exit 0 + +# Pre/post installation scripts: +%post +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_post %{name}.service +%else +/sbin/chkconfig --add %{name} +%endif + +%preun +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_preun %{name}.service +%else +/sbin/service %{name} stop >/dev/null 2>&1 +/sbin/chkconfig --del %{name} +%endif + +%postun +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_postun_with_restart %{name}.service +%else +/sbin/service %{name} start >/dev/null 2>&1 +%endif + + +%post thermos +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_post thermos-observer.service +%else +/sbin/chkconfig --add thermos-observer +%endif + +%preun thermos +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_preun thermos-observer.service +%else +/sbin/service thermos-observer stop >/dev/null 2>&1 +/sbin/chkconfig --del thermos-observer +%endif + +%postun thermos +%if 0%{?fedora} || 0%{?rhel} > 6 +%systemd_postun_with_restart thermos-observer.service +%else +/sbin/service thermos-observer start >/dev/null 2>&1 +%endif + + +%files +%defattr(-,root,root,-) +%doc docs/*.md +%{_bindir}/aurora-scheduler-startup +%attr(-,%{AURORA_USER},%{AURORA_GROUP}) %{_localstatedir}/lib/%{name} +%attr(-,%{AURORA_USER},%{AURORA_GROUP}) %{_localstatedir}/log/%{name} +%{_prefix}/lib/%{name}/bin/* +%{_prefix}/lib/%{name}/etc/* +%{_prefix}/lib/%{name}/lib/* +%if 0%{?fedora} || 0%{?rhel} > 6 +%{_sysconfdir}/systemd/system/%{name}.service +%else +%{_sysconfdir}/init.d/%{name} +%endif +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%config(noreplace) %{_sysconfdir}/sysconfig/%{name} + + +%files client +%defattr(-,root,root,-) +%{_bindir}/%{name} +%{_bindir}/%{name}_admin +%config(noreplace) %{_sysconfdir}/%{name}/clusters.json + + +%files thermos +%defattr(-,root,root,-) +%{_bindir}/thermos +%{_bindir}/thermos_executor +%{_bindir}/thermos_observer +%{_bindir}/thermos_runner +%{_bindir}/thermos-observer-startup +%{_localstatedir}/log/thermos +%{_localstatedir}/run/thermos +%if 0%{?fedora} || 0%{?rhel} > 6 +%{_sysconfdir}/systemd/system/thermos-observer.service +%else +%{_sysconfdir}/init.d/thermos-observer +%endif +%config(noreplace) %{_sysconfdir}/logrotate.d/thermos-observer +%config(noreplace) %{_sysconfdir}/sysconfig/thermos-observer + + +%changelog +* Tue Apr 14 2015 Steve Salevan <[email protected]> +- Initial specfile writeup. http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.startup.sh ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.startup.sh b/build-support/packaging/rpm/aurora.startup.sh new file mode 100644 index 0000000..3c444d9 --- /dev/null +++ b/build-support/packaging/rpm/aurora.startup.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Starts up an Aurora scheduler process. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +source /etc/sysconfig/aurora + +# Environment variables control the behavior of the Mesos scheduler driver (libmesos). +export GLOG_v LIBPROCESS_PORT LIBPROCESS_IP +export JAVA_OPTS="${JAVA_OPTS[*]}" + +# Preferences Java 1.8 over any other Java version. +export PATH=/usr/lib/jvm/java-1.8.0/bin:${PATH} + +exec /usr/lib/aurora/bin/aurora-scheduler "${AURORA_FLAGS[@]}" http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/aurora.sysconfig ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/aurora.sysconfig b/build-support/packaging/rpm/aurora.sysconfig new file mode 100644 index 0000000..b2a974f --- /dev/null +++ b/build-support/packaging/rpm/aurora.sysconfig @@ -0,0 +1,79 @@ +#!/bin/bash +# Configuration used when executing the Aurora task scheduler process. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +GLOG_v=0 + +LIBPROCESS_PORT=8083 +LIBPROCESS_IP='127.0.0.1' + +# Flags that control the behavior of the JVM. +JAVA_OPTS=( + # Uses server-level GC optimizations, as this is a server. + -server + + # Location of libmesos-XXXX.so / libmesos-XXXX.dylib + -Djava.library.path='/usr/lib;/usr/lib64' +) + +# Flags control the behavior of the Aurora scheduler. +# For a full list of available flags, run /usr/lib/aurora/bin/aurora-scheduler -help +AURORA_FLAGS=( + # The name of this cluster. + -cluster_name='main' + + # The HTTP port upon which Aurora will listen. + -http_port=8081 + + # The ZooKeeper URL of the ZNode where the Mesos master has registered. + -mesos_master_address='zk://127.0.0.1:2181/mesos/master' + + # The ZooKeeper quorum to which Aurora will register itself. + -zk_endpoints='127.0.0.1:2181' + + # The ZooKeeper ZNode within the specified quorum to which Aurora will register its + # ServerSet, which keeps track of all live Aurora schedulers. + -serverset_path='/aurora/scheduler' + + # The log level of the built-in logger. + -vlog='INFO' + + # Allows the scheduling of containers of the provided type. + -allowed_container_types='DOCKER,MESOS' + + ### Native Log Settings ### + + # The native log serves as a replicated database which stores the state of the + # scheduler, allowing for multi-master operation. + + # Size of the quorum of Aurora schedulers which possess a native log. If running in + # multi-master mode, consult the following document to determine appropriate values: + # + # https://aurora.apache.org/documentation/latest/deploying-aurora-scheduler/#replicated-log-configuration + -native_log_quorum_size='1' + # The ZooKeeper ZNode to which Aurora will register the locations of its replicated log. + -native_log_zk_group_path='/aurora/native-log' + # The local directory in which an Aurora scheduler can find Aurora's replicated log. + -native_log_file_path='/var/lib/aurora/db' + # The local directory in which Aurora schedulers will place state backups. + -backup_dir='/var/lib/aurora/backups' + + ### Thermos Settings ### + + # The local path of the Thermos executor binary. + -thermos_executor_path='/usr/bin/thermos_executor' + # Flags to pass to the Thermos executor. + -thermos_executor_flags='--announcer-enable --announcer-ensemble 127.0.0.1:2181' +) http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/clusters.json ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/clusters.json b/build-support/packaging/rpm/clusters.json new file mode 100644 index 0000000..133013b --- /dev/null +++ b/build-support/packaging/rpm/clusters.json @@ -0,0 +1,6 @@ +[{ + "name": "main", + "zk": "127.0.0.1", + "scheduler_zk_path": "/aurora/scheduler", + "auth_mechanism": "UNAUTHENTICATED" +}] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/thermos-observer.init.sh ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/thermos-observer.init.sh b/build-support/packaging/rpm/thermos-observer.init.sh new file mode 100644 index 0000000..65a2452 --- /dev/null +++ b/build-support/packaging/rpm/thermos-observer.init.sh @@ -0,0 +1,197 @@ +#!/bin/bash +# +# thermos-observer Starts the Thermos task observer. +# +# chkconfig: 345 55 25 +# description: This script starts the Thermos task observer, which provides a WebUI for \ +# viewing the state of tasks launched by the Thermos executor. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +### BEGIN INIT INFO +# Provides: thermos-observer +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Starts the Thermos task observer. +# Description: Starts the Thermos task observer. +### END INIT INFO + +# Source LSB function library. +. /lib/lsb/init-functions + +exec="/usr/bin/thermos-observer-startup" +prog="thermos-observer" +logdir="/var/log/thermos" +lockfile="/var/run/thermos-observer.lock" +pid_file="/var/run/thermos-observer.pid" + +stderr_log="${logdir}/observer.log" + +# Get a sane screen width +[ -z "${COLUMNS:-}" ] && COLUMNS=80 +[ -z "${CONSOLETYPE:-}" ] && CONSOLETYPE="$(/sbin/consoletype)" + +# Read in init configuration. +if [ -z "${BOOTUP:-}" ]; then + if [ -f /etc/sysconfig/init ]; then + . /etc/sysconfig/init + else + BOOTUP=color + RES_COL=60 + MOVE_TO_COL="echo -en \\033[${RES_COL}G" + SETCOLOR_SUCCESS="echo -en \\033[1;32m" + SETCOLOR_FAILURE="echo -en \\033[1;31m" + SETCOLOR_WARNING="echo -en \\033[1;33m" + SETCOLOR_NORMAL="echo -en \\033[0;39m" + LOGLEVEL=1 + fi + if [ "$CONSOLETYPE" = "serial" ]; then + BOOTUP=serial + MOVE_TO_COL= + SETCOLOR_SUCCESS= + SETCOLOR_FAILURE= + SETCOLOR_WARNING= + SETCOLOR_NORMAL= + fi +fi + +function usage { + err "Starts the Thermos task observer." + err "Usage: ${0} (restart|start|stop|status)" +} + +function out { + printf '%s\n' "$*"; +} + +function msg { + out "$*" >&2; +} + +function err { + local x=${?}; + msg "$*"; + return $(( ${x} == 0 ? 1 : ${x} )); +} + +function echo_success { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS + echo -n $" OK " + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 0 +} + +function echo_failure { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE + echo -n $"FAILED" + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 1 +} + +# Parse arguments. +ACTION=${1} + +# Ensures that action is. +if [ -z ${ACTION} ]; then + err "ERROR: No action specified." + usage + exit -1 +fi + +start() { + [ -x ${exec} ] || exit 5 + [ -f ${config} ] || exit 6 + echo -n $"Starting $prog: " + start_daemon daemonize -e ${stderr_log} -p ${pid_file} ${exec} + retval=$? + [ $retval -eq 0 ] && (echo_success; touch $lockfile) || echo_failure + echo + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + killproc -p ${pid_file} ${exec} + retval=$? + [ $retval -eq 0 ] && (echo_success; rm -f $lockfile) || echo_failure + echo + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + pid=$(pidofproc -p ${pid_file} ${prog}) + if [ $? -eq 0 ]; then + echo "${prog} (pid ${pid}) is running..." + return 0 + else + if [ -e $lockfile ]; then + echo "${prog} dead but lockfile exists" + return 2 + else + echo "${prog} is stopped" + return 1 + fi + fi +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + +# Executes the requested daemon action. +case "${ACTION}" in + start) + rh_status_q && rh_status && exit 0 + start + ;; + stop) + stop + ;; + status) + rh_status + ;; + restart) + restart + ;; + *) + err "ERROR: Invalid action specified." + usage + exit -3 +esac + +exit $? http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/thermos-observer.logrotate ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/thermos-observer.logrotate b/build-support/packaging/rpm/thermos-observer.logrotate new file mode 100644 index 0000000..a6a7f5c --- /dev/null +++ b/build-support/packaging/rpm/thermos-observer.logrotate @@ -0,0 +1,24 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +/var/log/thermos/*.log { + + daily + missingok + rotate 14 + compress + delaycompress + notifempty + copytruncate + +} http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/thermos-observer.service ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/thermos-observer.service b/build-support/packaging/rpm/thermos-observer.service new file mode 100644 index 0000000..d019635 --- /dev/null +++ b/build-support/packaging/rpm/thermos-observer.service @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[Unit] +Description=Thermos Observer +After=network.target +Wants=network.target + +[Service] +ExecStart=/usr/bin/thermos-observer-startup +User=root +Group=root +Restart=always +RestartSec=20 +LimitNOFILE=16384 + +[Install] +WantedBy=multi-user.target http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/thermos-observer.startup.sh ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/thermos-observer.startup.sh b/build-support/packaging/rpm/thermos-observer.startup.sh new file mode 100644 index 0000000..2d94fd9 --- /dev/null +++ b/build-support/packaging/rpm/thermos-observer.startup.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Starts up a Thermos observer process. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +source /etc/sysconfig/thermos-observer + +exec /usr/bin/thermos_observer "${OBSERVER_ARGS[@]}" http://git-wip-us.apache.org/repos/asf/aurora-packaging/blob/df6325c8/build-support/packaging/rpm/thermos-observer.sysconfig ---------------------------------------------------------------------- diff --git a/build-support/packaging/rpm/thermos-observer.sysconfig b/build-support/packaging/rpm/thermos-observer.sysconfig new file mode 100644 index 0000000..4bc5430 --- /dev/null +++ b/build-support/packaging/rpm/thermos-observer.sysconfig @@ -0,0 +1,22 @@ +#!/bin/bash +# Configuration used when executing the Thermos observer process. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +OBSERVER_ARGS=( + --root=/var/run/thermos + --port=1338 + --log_to_disk=NONE + --log_to_stderr=google:INFO +)
