bosh-gen 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +6 -0
- data/Gemfile +2 -2
- data/README.md +47 -23
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_setup.sh +2 -2
- data/lib/bosh/gen/generators/new_release_generator.rb +4 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/monit.tt +5 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/spec.tt +13 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/bin/%job_name%_ctl.tt +36 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/bin/monit_debugger +13 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/config/%job_name%.conf.erb.tt +5 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/config/.gitkeep +0 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/data/properties.sh.erb +10 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/helpers/ctl_setup.sh +81 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/helpers/ctl_utils.sh +156 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/deployment.yml.tt +1 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-aws-ec2.yml.tt +1 -1
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-warden.yml.tt +1 -1
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/jobs.yml.tt +2 -1
- data/lib/bosh/gen/generators/package_apt_generator/templates/Vagrantfile +1 -0
- data/lib/bosh/gen/generators/package_generator.rb +1 -1
- data/lib/bosh/gen/version.rb +1 -1
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ff840094fc8c4f6c7163f742b464942e246ef75
|
4
|
+
data.tar.gz: 525d03abe064affe81ae35d0a88ebeb99ec3ebad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cdcd0d98950bd188e01c025836ef211bf829f121c048f07ce43102a9b0775e0b8d523f48837fd5170006b58a1ac4951c1168ce7c54432f484a98bb5f9c9ab14
|
7
|
+
data.tar.gz: 8ea4f400fb757e263b14f92b2a189265c15b7db073a7dae43f1d1d20bd0c0c4e8a298db6c1b562c72dd9d97c2fe3e19bc711ed3a057d0c1f5c155ef083b5783c
|
data/ChangeLog.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v0.16.0
|
4
|
+
|
5
|
+
* `new` creates an initial job of the same name.
|
6
|
+
|
7
|
+
The initial job is configured to have the xyz.leader_address property, and an example conf file that shows how to use it.
|
8
|
+
|
3
9
|
## v0.15.0
|
4
10
|
|
5
11
|
* Create packages from existing Aptitude .deb packages with `package --apt`
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -53,41 +53,65 @@ $ bosh-gen template some-ruby-job config/some-config.ini
|
|
53
53
|
force jobs/some-ruby-job/spec
|
54
54
|
```
|
55
55
|
|
56
|
-
|
56
|
+
## Quickly creating packages
|
57
57
|
|
58
|
-
|
58
|
+
There is a slow way to create a package, and there are three faster ways. Slow vs fast is not a debated about best vs worse. But sometimes you're in a hurry.
|
59
59
|
|
60
|
-
|
60
|
+
### Slow way
|
61
61
|
|
62
62
|
```
|
63
|
-
$ bosh-gen
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
$ bosh-gen package apache2
|
64
|
+
```
|
65
|
+
|
66
|
+
The slowest way to create a package is to run the command above, then get the source, read the "install from source" instructions, and create a package.
|
67
|
+
|
68
|
+
### Slightly faster way
|
69
69
|
|
70
|
-
Edit jobs/micro/prepare_spec with ordered list of jobs to include
|
71
|
-
in micro job. The order of jobs implicitly specifies the order in
|
72
|
-
which they are started.
|
73
70
|
```
|
71
|
+
$ bosh-gen package redis -f ~/Downloads/redis-2.8.3.tar.gz
|
72
|
+
```
|
73
|
+
|
74
|
+
If you download the source files first, and reference them with the `bosh-gen package` generator, then it will attempt to guess how to install the package. The generated `packaging` script will include some starting commands that might work.
|
74
75
|
|
75
|
-
|
76
|
+
The command above will also copy the target file into the `blobs/redis/` folder. One less thing for you to do.
|
76
77
|
|
77
|
-
|
78
|
+
### Fastest way - reuse existing packages
|
78
79
|
|
79
80
|
```
|
80
|
-
$ bosh
|
81
|
-
...
|
82
|
-
Jobs
|
83
|
-
+----------+---------+-------+------------------------------------------+
|
84
|
-
| Name | Version | Notes | Fingerprint |
|
85
|
-
+----------+---------+-------+------------------------------------------+
|
86
|
-
...
|
87
|
-
| micro | 0.1-dev | | 6eb2f98644ef7f61a0399c015cbe062987dfd498 |
|
88
|
-
+----------+---------+-------+------------------------------------------+
|
81
|
+
$ bosh-gen extract-pkg ../cf-release/packages/postgres
|
89
82
|
```
|
90
83
|
|
84
|
+
The fastest way is to reuse an existing, working package from another BOSH release that you have on your local machine.
|
85
|
+
|
86
|
+
This command will copy across the `packages/postgres/spec` & `packages/postgres/packaging` files, as well as any blobs or src files that are referenced in the original BOSH release.
|
87
|
+
|
88
|
+
This is a great command to use. There are a growing number of BOSH releases on GitHub from which to steal, err, extract packages into your own BOSH releases.
|
89
|
+
|
90
|
+
Remember, first run `bosh sync blobs` in the target BOSH release project. Otherwise it will not be able to copy over the blobs.
|
91
|
+
|
92
|
+
### Fast way - reuse Aptitude/Debian packages
|
93
|
+
|
94
|
+
```
|
95
|
+
$ bosh-gen package apache2 --apt
|
96
|
+
$ vagrant up
|
97
|
+
$ vagrant ssh -c '/vagrant/src/apt/fetch_debs.sh apache2'
|
98
|
+
$ vagrant destroy
|
99
|
+
```
|
100
|
+
|
101
|
+
You can add/change the Debian packages to install by editing `src/apt/apache2/aptfile` and re-running the `fetch_debs.sh` command above. You might want to delete `blobs/apt/apache2` first to ensure that only the fetched `.deb` files are subsequently included during package compilation.
|
102
|
+
|
103
|
+
It is possible now to download one or more `.deb` files into the `blobs/apt/` folder, and have them installed during package compilation time.
|
104
|
+
|
105
|
+
The installed .deb packages will be available at `/var/vcap/packages/apache2/apt`; rather than within the root folder system.
|
106
|
+
|
107
|
+
Your job monit control scripts can source a provided `profile.sh` to setup environment variables:
|
108
|
+
|
109
|
+
```
|
110
|
+
source /var/vcap/packages/apache2/profile.sh
|
111
|
+
```
|
112
|
+
|
113
|
+
This is the last option, and it is not the best option. Many Debian packages will also start processes that have default configuration that is not correct for your use case. It may be fast to get the Debian packages; but additional work may be required by your jobs to stop and unhook the processes that are automatically started upon installation.
|
114
|
+
|
91
115
|
## Tutorial
|
92
116
|
|
93
117
|
To see how the various commands work together, let's create a new bosh release for [Cassandra](http://cassandra.apache.org/ "The Apache Cassandra Project").
|
@@ -14,7 +14,7 @@ set -e # exit immediately if a simple command exits with a non-zero status
|
|
14
14
|
set -u # report the usage of uninitialized variables
|
15
15
|
|
16
16
|
JOB_NAME=$1
|
17
|
-
output_label=${
|
17
|
+
output_label=${2:-${JOB_NAME}}
|
18
18
|
|
19
19
|
export JOB_DIR=/var/vcap/jobs/$JOB_NAME
|
20
20
|
chmod 755 $JOB_DIR # to access file via symlink
|
@@ -76,6 +76,6 @@ do
|
|
76
76
|
export CLASSPATH=${java_jar}:$CLASSPATH
|
77
77
|
done
|
78
78
|
|
79
|
-
PIDFILE=$RUN_DIR/$
|
79
|
+
PIDFILE=$RUN_DIR/$output_label.pid
|
80
80
|
|
81
81
|
echo '$PATH' $PATH
|
@@ -185,6 +185,10 @@ module Bosh::Gen
|
|
185
185
|
@project_name ||= File.basename(proposed_app_path).gsub(/-(?:boshrelease|release)$/, '')
|
186
186
|
end
|
187
187
|
|
188
|
+
def job_name
|
189
|
+
project_name_underscored
|
190
|
+
end
|
191
|
+
|
188
192
|
def project_name_hyphenated
|
189
193
|
project_name.gsub(/[^A-Za-z]+/, '-')
|
190
194
|
end
|
data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/monit.tt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
check process <%= job_name %>
|
2
|
+
with pidfile /var/vcap/sys/run/<%= job_name %>/<%= job_name %>.pid
|
3
|
+
start program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger <%= job_name %>_ctl '/var/vcap/jobs/<%= job_name %>/bin/<%= job_name %>_ctl start'"
|
4
|
+
stop program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger <%= job_name %>_ctl '/var/vcap/jobs/<%= job_name %>/bin/<%= job_name %>_ctl stop'"
|
5
|
+
group vcap
|
data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/spec.tt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
name: <%= project_name_hyphenated %>
|
3
|
+
packages: []
|
4
|
+
templates:
|
5
|
+
bin/monit_debugger: bin/monit_debugger
|
6
|
+
bin/<%= job_name %>_ctl: bin/<%= job_name %>_ctl
|
7
|
+
config/<%= job_name %>.conf.erb: config/<%= job_name %>.conf
|
8
|
+
data/properties.sh.erb: data/properties.sh
|
9
|
+
helpers/ctl_setup.sh: helpers/ctl_setup.sh
|
10
|
+
helpers/ctl_utils.sh: helpers/ctl_utils.sh
|
11
|
+
properties:
|
12
|
+
<%= project_name_underscored %>.leader_address:
|
13
|
+
description: Hostname/IP to the leader/master of the cluster
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e # exit immediately if a simple command exits with a non-zero status
|
4
|
+
set -u # report the usage of uninitialized variables
|
5
|
+
|
6
|
+
# Setup env vars and folders for the webapp_ctl script
|
7
|
+
source /var/vcap/jobs/<%= job_name %>/helpers/ctl_setup.sh '<%= job_name %>'
|
8
|
+
|
9
|
+
export PORT=${PORT:-5000}
|
10
|
+
export LANG=en_US.UTF-8
|
11
|
+
|
12
|
+
case $1 in
|
13
|
+
|
14
|
+
start)
|
15
|
+
pid_guard $PIDFILE $JOB_NAME
|
16
|
+
|
17
|
+
# TODO: Run some process
|
18
|
+
exec TODO \
|
19
|
+
>>$LOG_DIR/$JOB_NAME.stdout.log \
|
20
|
+
2>>$LOG_DIR/$JOB_NAME.stderr.log
|
21
|
+
|
22
|
+
# store pid in $PIDFILE
|
23
|
+
echo $! > $PIDFILE
|
24
|
+
;;
|
25
|
+
|
26
|
+
stop)
|
27
|
+
kill_and_wait $PIDFILE
|
28
|
+
|
29
|
+
;;
|
30
|
+
*)
|
31
|
+
echo "Usage: <%= job_name %>_ctl {start|stop}"
|
32
|
+
|
33
|
+
;;
|
34
|
+
|
35
|
+
esac
|
36
|
+
exit 0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# USAGE monit_debugger <label> command to run
|
3
|
+
mkdir -p /var/vcap/sys/log/monit
|
4
|
+
{
|
5
|
+
echo "MONIT-DEBUG date"
|
6
|
+
date
|
7
|
+
echo "MONIT-DEBUG env"
|
8
|
+
env
|
9
|
+
echo "MONIT-DEBUG $@"
|
10
|
+
$2 $3 $4 $5 $6 $7
|
11
|
+
R=$?
|
12
|
+
echo "MONIT-DEBUG exit code $R"
|
13
|
+
} >/var/vcap/sys/log/monit/monit_debugger.$1.log 2>&1
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Example of how to do one thing when job is master/leader, and another thing if its follower/slave
|
2
|
+
# See templates/infrastructure-warden.yml & templates/jobs.yml for where this value originates
|
3
|
+
<%% if_p("<%= project_name_underscored %>.leader_address") do |leader_address| %>
|
4
|
+
leader: <%%= leader_address %>
|
5
|
+
<%% end %>
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# job template binding variables
|
4
|
+
|
5
|
+
# job name & index of this VM within cluster
|
6
|
+
# e.g. JOB_NAME=redis, JOB_INDEX=0
|
7
|
+
export NAME='<%= name %>'
|
8
|
+
export JOB_INDEX=<%= index %>
|
9
|
+
# full job name, like redis/0 or webapp/3
|
10
|
+
export JOB_FULL="$NAME/$JOB_INDEX"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Setup env vars and folders for the ctl script
|
4
|
+
# This helps keep the ctl script as readable
|
5
|
+
# as possible
|
6
|
+
|
7
|
+
# Usage options:
|
8
|
+
# source /var/vcap/jobs/foobar/helpers/ctl_setup.sh JOB_NAME OUTPUT_LABEL
|
9
|
+
# source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar
|
10
|
+
# source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar foobar
|
11
|
+
# source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar nginx
|
12
|
+
|
13
|
+
set -e # exit immediately if a simple command exits with a non-zero status
|
14
|
+
set -u # report the usage of uninitialized variables
|
15
|
+
|
16
|
+
JOB_NAME=$1
|
17
|
+
output_label=${1:-JOB_NAME}
|
18
|
+
|
19
|
+
export JOB_DIR=/var/vcap/jobs/$JOB_NAME
|
20
|
+
chmod 755 $JOB_DIR # to access file via symlink
|
21
|
+
|
22
|
+
# Load some bosh deployment properties into env vars
|
23
|
+
# Try to put all ERb into data/properties.sh.erb
|
24
|
+
# incl $NAME, $JOB_INDEX, $WEBAPP_DIR
|
25
|
+
source $JOB_DIR/data/properties.sh
|
26
|
+
|
27
|
+
source $JOB_DIR/helpers/ctl_utils.sh
|
28
|
+
redirect_output ${output_label}
|
29
|
+
|
30
|
+
export HOME=${HOME:-/home/vcap}
|
31
|
+
|
32
|
+
# Add all packages' /bin & /sbin into $PATH
|
33
|
+
for package_bin_dir in $(ls -d /var/vcap/packages/*/*bin)
|
34
|
+
do
|
35
|
+
export PATH=${package_bin_dir}:$PATH
|
36
|
+
done
|
37
|
+
|
38
|
+
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-''} # default to empty
|
39
|
+
for package_bin_dir in $(ls -d /var/vcap/packages/*/lib)
|
40
|
+
do
|
41
|
+
export LD_LIBRARY_PATH=${package_bin_dir}:$LD_LIBRARY_PATH
|
42
|
+
done
|
43
|
+
|
44
|
+
# Setup log, run and tmp folders
|
45
|
+
|
46
|
+
export RUN_DIR=/var/vcap/sys/run/$JOB_NAME
|
47
|
+
export LOG_DIR=/var/vcap/sys/log/$JOB_NAME
|
48
|
+
export TMP_DIR=/var/vcap/sys/tmp/$JOB_NAME
|
49
|
+
export STORE_DIR=/var/vcap/store/$JOB_NAME
|
50
|
+
for dir in $RUN_DIR $LOG_DIR $TMP_DIR $STORE_DIR
|
51
|
+
do
|
52
|
+
mkdir -p ${dir}
|
53
|
+
chown vcap:vcap ${dir}
|
54
|
+
chmod 775 ${dir}
|
55
|
+
done
|
56
|
+
export TMPDIR=$TMP_DIR
|
57
|
+
|
58
|
+
export C_INCLUDE_PATH=/var/vcap/packages/mysqlclient/include/mysql:/var/vcap/packages/sqlite/include:/var/vcap/packages/libpq/include
|
59
|
+
export LIBRARY_PATH=/var/vcap/packages/mysqlclient/lib/mysql:/var/vcap/packages/sqlite/lib:/var/vcap/packages/libpq/lib
|
60
|
+
|
61
|
+
# consistent place for vendoring python libraries within package
|
62
|
+
if [[ -d ${WEBAPP_DIR:-/xxxx} ]]
|
63
|
+
then
|
64
|
+
export PYTHONPATH=$WEBAPP_DIR/vendor/lib/python
|
65
|
+
fi
|
66
|
+
|
67
|
+
if [[ -d /var/vcap/packages/java7 ]]
|
68
|
+
then
|
69
|
+
export JAVA_HOME="/var/vcap/packages/java7"
|
70
|
+
fi
|
71
|
+
|
72
|
+
# setup CLASSPATH for all jars/ folders within packages
|
73
|
+
export CLASSPATH=${CLASSPATH:-''} # default to empty
|
74
|
+
for java_jar in $(ls -d /var/vcap/packages/*/*/*.jar)
|
75
|
+
do
|
76
|
+
export CLASSPATH=${java_jar}:$CLASSPATH
|
77
|
+
done
|
78
|
+
|
79
|
+
PIDFILE=$RUN_DIR/$JOB_NAME.pid
|
80
|
+
|
81
|
+
echo '$PATH' $PATH
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# Helper functions used by ctl scripts
|
2
|
+
|
3
|
+
# links a job file (probably a config file) into a package
|
4
|
+
# Example usage:
|
5
|
+
# link_job_file_to_package config/redis.yml [config/redis.yml]
|
6
|
+
# link_job_file_to_package config/wp-config.php wp-config.php
|
7
|
+
link_job_file_to_package() {
|
8
|
+
source_job_file=$1
|
9
|
+
target_package_file=${2:-$source_job_file}
|
10
|
+
full_package_file=$WEBAPP_DIR/${target_package_file}
|
11
|
+
|
12
|
+
link_job_file ${source_job_file} ${full_package_file}
|
13
|
+
}
|
14
|
+
|
15
|
+
# links a job file (probably a config file) somewhere
|
16
|
+
# Example usage:
|
17
|
+
# link_job_file config/bashrc /home/vcap/.bashrc
|
18
|
+
link_job_file() {
|
19
|
+
source_job_file=$1
|
20
|
+
target_file=$2
|
21
|
+
full_job_file=$JOB_DIR/${source_job_file}
|
22
|
+
|
23
|
+
echo link_job_file ${full_job_file} ${target_file}
|
24
|
+
if [[ ! -f ${full_job_file} ]]
|
25
|
+
then
|
26
|
+
echo "file to link ${full_job_file} does not exist"
|
27
|
+
else
|
28
|
+
# Create/recreate the symlink to current job file
|
29
|
+
# If another process is using the file, it won't be
|
30
|
+
# deleted, so don't attempt to create the symlink
|
31
|
+
mkdir -p $(dirname ${target_file})
|
32
|
+
ln -nfs ${full_job_file} ${target_file}
|
33
|
+
fi
|
34
|
+
}
|
35
|
+
|
36
|
+
# If loaded within monit ctl scripts then pipe output
|
37
|
+
# If loaded from 'source ../utils.sh' then normal STDOUT
|
38
|
+
redirect_output() {
|
39
|
+
SCRIPT=$1
|
40
|
+
mkdir -p /var/vcap/sys/log/monit
|
41
|
+
exec 1>> /var/vcap/sys/log/monit/$SCRIPT.log
|
42
|
+
exec 2>> /var/vcap/sys/log/monit/$SCRIPT.err.log
|
43
|
+
}
|
44
|
+
|
45
|
+
pid_guard() {
|
46
|
+
pidfile=$1
|
47
|
+
name=$2
|
48
|
+
|
49
|
+
if [ -f "$pidfile" ]; then
|
50
|
+
pid=$(head -1 "$pidfile")
|
51
|
+
|
52
|
+
if [ -n "$pid" ] && [ -e /proc/$pid ]; then
|
53
|
+
echo "$name is already running, please stop it first"
|
54
|
+
exit 1
|
55
|
+
fi
|
56
|
+
|
57
|
+
echo "Removing stale pidfile..."
|
58
|
+
rm $pidfile
|
59
|
+
fi
|
60
|
+
}
|
61
|
+
|
62
|
+
wait_pid() {
|
63
|
+
pid=$1
|
64
|
+
try_kill=$2
|
65
|
+
timeout=${3:-0}
|
66
|
+
force=${4:-0}
|
67
|
+
countdown=$(( $timeout * 10 ))
|
68
|
+
|
69
|
+
echo wait_pid $pid $try_kill $timeout $force $countdown
|
70
|
+
if [ -e /proc/$pid ]; then
|
71
|
+
if [ "$try_kill" = "1" ]; then
|
72
|
+
echo "Killing $pidfile: $pid "
|
73
|
+
kill $pid
|
74
|
+
fi
|
75
|
+
while [ -e /proc/$pid ]; do
|
76
|
+
sleep 0.1
|
77
|
+
[ "$countdown" != '0' -a $(( $countdown % 10 )) = '0' ] && echo -n .
|
78
|
+
if [ $timeout -gt 0 ]; then
|
79
|
+
if [ $countdown -eq 0 ]; then
|
80
|
+
if [ "$force" = "1" ]; then
|
81
|
+
echo -ne "\nKill timed out, using kill -9 on $pid... "
|
82
|
+
kill -9 $pid
|
83
|
+
sleep 0.5
|
84
|
+
fi
|
85
|
+
break
|
86
|
+
else
|
87
|
+
countdown=$(( $countdown - 1 ))
|
88
|
+
fi
|
89
|
+
fi
|
90
|
+
done
|
91
|
+
if [ -e /proc/$pid ]; then
|
92
|
+
echo "Timed Out"
|
93
|
+
else
|
94
|
+
echo "Stopped"
|
95
|
+
fi
|
96
|
+
else
|
97
|
+
echo "Process $pid is not running"
|
98
|
+
echo "Attempting to kill pid anyway..."
|
99
|
+
kill $pid
|
100
|
+
fi
|
101
|
+
}
|
102
|
+
|
103
|
+
wait_pidfile() {
|
104
|
+
pidfile=$1
|
105
|
+
try_kill=$2
|
106
|
+
timeout=${3:-0}
|
107
|
+
force=${4:-0}
|
108
|
+
countdown=$(( $timeout * 10 ))
|
109
|
+
|
110
|
+
if [ -f "$pidfile" ]; then
|
111
|
+
pid=$(head -1 "$pidfile")
|
112
|
+
if [ -z "$pid" ]; then
|
113
|
+
echo "Unable to get pid from $pidfile"
|
114
|
+
exit 1
|
115
|
+
fi
|
116
|
+
|
117
|
+
wait_pid $pid $try_kill $timeout $force
|
118
|
+
|
119
|
+
rm -f $pidfile
|
120
|
+
else
|
121
|
+
echo "Pidfile $pidfile doesn't exist"
|
122
|
+
fi
|
123
|
+
}
|
124
|
+
|
125
|
+
kill_and_wait() {
|
126
|
+
pidfile=$1
|
127
|
+
# Monit default timeout for start/stop is 30s
|
128
|
+
# Append 'with timeout {n} seconds' to monit start/stop program configs
|
129
|
+
timeout=${2:-25}
|
130
|
+
force=${3:-1}
|
131
|
+
if [[ -f ${pidfile} ]]
|
132
|
+
then
|
133
|
+
wait_pidfile $pidfile 1 $timeout $force
|
134
|
+
else
|
135
|
+
# TODO assume $1 is something to grep from 'ps ax'
|
136
|
+
pid="$(ps auwwx | grep "$1" | awk '{print $2}')"
|
137
|
+
wait_pid $pid 1 $timeout $force
|
138
|
+
fi
|
139
|
+
}
|
140
|
+
|
141
|
+
check_nfs_mount() {
|
142
|
+
opts=$1
|
143
|
+
exports=$2
|
144
|
+
mount_point=$3
|
145
|
+
|
146
|
+
if grep -qs $mount_point /proc/mounts; then
|
147
|
+
echo "Found NFS mount $mount_point"
|
148
|
+
else
|
149
|
+
echo "Mounting NFS..."
|
150
|
+
mount $opts $exports $mount_point
|
151
|
+
if [ $? != 0 ]; then
|
152
|
+
echo "Cannot mount NFS from $exports to $mount_point, exiting..."
|
153
|
+
exit 1
|
154
|
+
fi
|
155
|
+
fi
|
156
|
+
}
|
data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-aws-ec2.yml.tt
CHANGED
@@ -18,7 +18,7 @@ jobs:
|
|
18
18
|
networks:
|
19
19
|
- name: (( meta.network_name ))
|
20
20
|
properties:
|
21
|
-
|
21
|
+
<%= project_name_underscored %>:
|
22
22
|
leader_address: (( "0.<%= project_name_hyphenated %>-leader-z1.<%= project_name_hyphenated %>1." meta.environment "." meta.dns_root ))
|
23
23
|
|
24
24
|
compilation:
|
data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-warden.yml.tt
CHANGED
@@ -25,7 +25,7 @@ jobs:
|
|
25
25
|
static_ips: ~
|
26
26
|
properties:
|
27
27
|
<%= project_name_underscored %>:
|
28
|
-
|
28
|
+
leader_address: (( jobs.<%= project_name_underscored %>_leader_z1.networks.<%= project_name_underscored %>1.static_ips.[0] ))
|
29
29
|
|
30
30
|
compilation:
|
31
31
|
cloud_properties:
|
@@ -6,6 +6,7 @@ update:
|
|
6
6
|
max_in_flight: 50
|
7
7
|
canary_watch_time: 1000-30000
|
8
8
|
update_watch_time: 1000-30000
|
9
|
+
serial: false
|
9
10
|
|
10
11
|
jobs:
|
11
12
|
- name: <%= project_name_underscored %>_leader_z1
|
@@ -22,7 +23,7 @@ jobs:
|
|
22
23
|
canaries: 10
|
23
24
|
properties:
|
24
25
|
<%= project_name_underscored %>:
|
25
|
-
|
26
|
+
leader_address: (( merge ))
|
26
27
|
|
27
28
|
networks: (( merge ))
|
28
29
|
|
@@ -4,6 +4,7 @@ Vagrant.configure('2') do |config|
|
|
4
4
|
|
5
5
|
config.vm.hostname='boshrelease-builder'
|
6
6
|
config.vm.box = "lucid64"
|
7
|
+
config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
|
7
8
|
|
8
9
|
# Need NFS enabled, and hence a private network for virtualbox
|
9
10
|
# as discussed in this project's patch
|
@@ -43,7 +43,7 @@ module Bosh::Gen
|
|
43
43
|
set -u # report the usage of uninitialized variables
|
44
44
|
|
45
45
|
# Detect # of CPUs so make jobs can be parallelized
|
46
|
-
CPUS
|
46
|
+
CPUS=$(grep -c ^processor /proc/cpuinfo)
|
47
47
|
|
48
48
|
# Available variables
|
49
49
|
# $BOSH_COMPILE_TARGET - where this package & spec'd source files are available
|
data/lib/bosh/gen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -162,6 +162,15 @@ files:
|
|
162
162
|
- lib/bosh/gen/generators/new_release_generator/templates/README.md.tt
|
163
163
|
- lib/bosh/gen/generators/new_release_generator/templates/Rakefile
|
164
164
|
- lib/bosh/gen/generators/new_release_generator/templates/blobs/.gitkeep
|
165
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/monit.tt
|
166
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/spec.tt
|
167
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/bin/%job_name%_ctl.tt
|
168
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/bin/monit_debugger
|
169
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/config/%job_name%.conf.erb.tt
|
170
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/config/.gitkeep
|
171
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/data/properties.sh.erb
|
172
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/helpers/ctl_setup.sh
|
173
|
+
- lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/helpers/ctl_utils.sh
|
165
174
|
- lib/bosh/gen/generators/new_release_generator/templates/jobs/.gitkeep
|
166
175
|
- lib/bosh/gen/generators/new_release_generator/templates/packages/.gitkeep
|
167
176
|
- lib/bosh/gen/generators/new_release_generator/templates/src/.gitkeep
|
@@ -254,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
263
|
version: '0'
|
255
264
|
requirements: []
|
256
265
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.2.
|
266
|
+
rubygems_version: 2.2.1
|
258
267
|
signing_key:
|
259
268
|
specification_version: 4
|
260
269
|
summary: ''
|