Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Create run dir in start script and run stop as root
Browse files Browse the repository at this point in the history
[#119388013]
  • Loading branch information
christianang committed Jun 8, 2016
1 parent 60ca714 commit 33a03cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion jobs/consul_agent/monit
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ check process consul_agent
start program "/var/vcap/jobs/consul_agent/bin/agent_ctl start"
as uid vcap and gid vcap with timeout 60 seconds
stop program "/var/vcap/jobs/consul_agent/bin/agent_ctl stop"
as uid vcap and gid vcap
group vcap

<% if p("consul.agent.mode") == "server" && !p("consul.agent.servers.wan").empty? %>
Expand Down
8 changes: 8 additions & 0 deletions jobs/consul_agent/templates/agent_ctl.sh.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash -exu

SCRIPT_NAME=$(basename $0)
RUN_DIR=/var/vcap/sys/run/consul_agent
LOG_DIR=/var/vcap/sys/log/consul_agent
JOB_DIR=/var/vcap/jobs/consul_agent
CONFAB_PACKAGE=/var/vcap/packages/confab
Expand Down Expand Up @@ -35,7 +36,14 @@ function stop_confab() {
2> >(tee -a ${LOG_DIR}/consul_agent.stderr.log | logger -p user.error -t vcap.consul-agent)
}

function create_run_directory() {
mkdir -p "${RUN_DIR}"
chown -R vcap:vcap "${RUN_DIR}"
}

function main() {
create_run_directory

case ${1} in
start)
start_confab
Expand Down
4 changes: 0 additions & 4 deletions jobs/consul_agent/templates/pre-start.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash -exu

LOG_DIR=/var/vcap/sys/log/consul_agent
RUN_DIR=/var/vcap/sys/run/consul_agent
DATA_DIR=/var/vcap/store/consul_agent
CONF_DIR=/var/vcap/jobs/consul_agent/config
CERT_DIR=$CONF_DIR/certs
Expand All @@ -26,9 +25,6 @@ function create_directories_and_chown_to_vcap() {
mkdir -p "${LOG_DIR}"
chown -R vcap:vcap "${LOG_DIR}"

mkdir -p "${RUN_DIR}"
chown -R vcap:vcap "${RUN_DIR}"

mkdir -p "${DATA_DIR}"
chown -R vcap:vcap "${DATA_DIR}"

Expand Down

0 comments on commit 33a03cb

Please sign in to comment.