Skip to content

Instantly share code, notes, and snippets.

@geoffgarside
Last active January 14, 2016 11:58
Show Gist options
  • Save geoffgarside/3a985a771d280052309d to your computer and use it in GitHub Desktop.
Save geoffgarside/3a985a771d280052309d to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# PROVIDE: gitlab_ci_runner
# REQUIRE: networking syslog
# KEYWORD: shutdown
. /etc/rc.subr
name="gitlab_ci_runner"
rcvar="${name}_enable"
load_rc_config "${name}"
: ${gitlab_ci_runner_enable:="NO"}
: ${gitlab_ci_runner_user:=""}
: ${gitlab_ci_runner_config:="/etc/gitlab-runner/config.toml"}
: ${gitlab_ci_runner_workdir:="/var/gitlab-runner"}
: ${gitlab_ci_runner_pidfile:="/var/run/gitlab-runner.pid"}
: ${gitlab_ci_runner_logfile:="/var/log/gitlab-runner.log"}
command="/usr/local/bin/gitlab-ci-multi-runner"
command_args="run -c ${gitlab_ci_runner_config} -d ${gitlab_ci_runner_workdir}"
required_dirs="${gitlab_ci_runner_workdir}"
required_files="${gitlab_ci_runner_config}"
pidfile="${gitlab_ci_runner_pidfile}"
start_cmd=golang_start
golang_start() {
daemon_args="-p ${pidfile}"
if [ -n "${gitlab_ci_runner_user}" -a "${gitlab_ci_runner_user}" != "root" ]; then
daemon_args="${daemon_args} -u ${gitlab_ci_runner_user}"
fi
export PATH="${PATH}:/usr/local/bin"
debug "/usr/sbin/daemon ${daemon_args} -- ${command} ${command_args}"
/usr/sbin/daemon ${daemon_args} -- ${command} ${command_args} > ${gitlab_ci_runner_logfile} 2> ${gitlab_ci_runner_logfile}
}
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment