bosh-gen 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.md +13 -0
- data/lib/bosh/gen/cli.rb +45 -29
- data/lib/bosh/gen/generators/deployment_manifest_generator.rb +7 -3
- data/lib/bosh/gen/generators/extract_job_generator.rb +37 -6
- data/lib/bosh/gen/generators/extract_package_generator.rb +23 -5
- data/lib/bosh/gen/generators/job_generator.rb +34 -16
- data/lib/bosh/gen/generators/job_generator/templates/examples/%job_name%_nginx_rack/nginx_puma_migrate.yml +14 -0
- data/lib/bosh/gen/generators/job_generator/templates/examples/%job_name%_nginx_rack/nginx_rackup.yml.tt +8 -0
- data/lib/bosh/gen/generators/job_generator/templates/examples/%job_name%_simple/default.yml +2 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/monit.tt +13 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/%job_name%_rack_ctl.tt +59 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_db_utils.sh.erb +54 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_nginx.sh.erb +17 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_redis_utils.sh.erb +18 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_setup.sh.erb +48 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_start.sh.erb +59 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_utils.sh +148 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/monit_debugger +13 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/nginx_ctl.tt +41 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/rails_ctl_setup.sh.erb +40 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/database.yml.erb +17 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/mime.types +73 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/nginx.conf.erb +150 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/nginx_proxy.conf +11 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/redis.yml.erb +6 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/monit.tt +5 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/bin/%job_name%_ctl.tt +36 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/bin/monit_debugger +13 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/data/properties.sh.erb +10 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_setup.sh +81 -0
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_utils.sh +156 -0
- data/lib/bosh/gen/generators/package_generator.rb +56 -10
- data/lib/bosh/gen/models.rb +1 -0
- data/lib/bosh/gen/models/bosh_config.rb +15 -0
- data/lib/bosh/gen/models/deployment_manifest.rb +5 -0
- data/lib/bosh/gen/version.rb +1 -1
- data/spec/fixtures/bosh_config/multiple_boshes.yml +34 -0
- data/spec/fixtures/deployment_manifests/2_jobs_1_ip_8196_disk.yml +2 -2
- data/spec/fixtures/deployment_manifests/2_jobs_2_ips_no_disk.yml +2 -2
- data/spec/generators/generator_spec_helper.rb +102 -0
- data/spec/generators/jobs/webapp_job_generator_spec.rb +68 -0
- data/spec/models/bosh_config_spec.rb +11 -0
- metadata +38 -8
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%/monit.tt +0 -5
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%/templates/%job_name%_ctl.tt +0 -62
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_rubyrack/monit.tt +0 -5
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_rubyrack/templates/%job_name%_ctl.tt +0 -64
data/ChangeLog.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v0.9.0
|
4
|
+
|
5
|
+
Major news
|
6
|
+
|
7
|
+
* `job` - more powerful initial scripts; templates nested in folders; scripts are much cleaner to read; scripts in bin/ & helpers/ do not have ERb; only data/properties.sh.erb & config/ are for ERb.
|
8
|
+
|
9
|
+
Other changes:
|
10
|
+
|
11
|
+
* `package` - detects .zip files (in addition to .tar.gz) and includes useful default unpacking script in `packaging`; describe available env vars in `packaging` script
|
12
|
+
* `manifest` - auto-detects current BOSH UUID
|
13
|
+
* `extract-pkg` - now a single argument - the path of the source package folder
|
14
|
+
* `extract-job` - now a single argument - the path of the source job folder
|
15
|
+
|
3
16
|
## v0.8.0
|
4
17
|
|
5
18
|
Changed:
|
data/lib/bosh/gen/cli.rb
CHANGED
@@ -13,8 +13,10 @@ module Bosh
|
|
13
13
|
include Thor::Actions
|
14
14
|
|
15
15
|
desc "new PATH", "Creates a new BOSH release"
|
16
|
-
method_option :s3, :alias => ["--aws"], :type => :boolean,
|
17
|
-
|
16
|
+
method_option :s3, :alias => ["--aws"], :type => :boolean,
|
17
|
+
:desc => "Use AWS S3 bucket for blobstore"
|
18
|
+
method_option :atmos, :type => :boolean,
|
19
|
+
:desc => "Use EMC ATMOS for blobstore"
|
18
20
|
def new(path)
|
19
21
|
flags = { :aws => options["s3"], :atmos => options["atmos"] }
|
20
22
|
|
@@ -23,17 +25,21 @@ module Bosh
|
|
23
25
|
end
|
24
26
|
|
25
27
|
desc "package NAME", "Create a new package"
|
26
|
-
method_option :dependencies, :aliases => ['-d'], :type => :array,
|
27
|
-
|
28
|
+
method_option :dependencies, :aliases => ['-d'], :type => :array,
|
29
|
+
:desc => "List of package dependencies"
|
30
|
+
method_option :files, :aliases => ['-f', '--src'], :type => :array,
|
31
|
+
:desc => "List of files copy into release"
|
28
32
|
def package(name)
|
29
33
|
dependencies = options[:dependencies] || []
|
30
34
|
files = options[:files] || []
|
31
35
|
require 'bosh/gen/generators/package_generator'
|
32
|
-
Bosh::Gen::Generators::PackageGenerator.start(
|
36
|
+
Bosh::Gen::Generators::PackageGenerator.start(
|
37
|
+
[name, dependencies, files])
|
33
38
|
end
|
34
39
|
|
35
40
|
desc "source NAME", "Downloads a source item into the named project"
|
36
|
-
method_option :blob, :aliases => ['-b'], :type => :boolean,
|
41
|
+
method_option :blob, :aliases => ['-b'], :type => :boolean,
|
42
|
+
:desc => "Store file in blobstore"
|
37
43
|
def source(name, uri)
|
38
44
|
flags = { :blob => options[:blob] || false }
|
39
45
|
dir = Dir.mktmpdir
|
@@ -49,49 +55,59 @@ module Bosh
|
|
49
55
|
end
|
50
56
|
|
51
57
|
require 'bosh/gen/generators/package_source_generator'
|
52
|
-
Bosh::Gen::Generators::PackageSourceGenerator.start(
|
58
|
+
Bosh::Gen::Generators::PackageSourceGenerator.start(
|
59
|
+
[name, files, flags])
|
53
60
|
end
|
54
61
|
|
55
|
-
desc "job NAME
|
56
|
-
method_option :dependencies, :aliases => ['-d'], :type => :array,
|
57
|
-
|
58
|
-
def job(name
|
59
|
-
|
60
|
-
flags = { :ruby => options["ruby"] || false }
|
61
|
-
dependencies = options[:dependencies] || []
|
62
|
+
desc "job NAME", "Create a new job"
|
63
|
+
method_option :dependencies, :aliases => ['-d'], :type => :array,
|
64
|
+
:desc => "List of package dependencies"
|
65
|
+
def job(name)
|
66
|
+
dependencies = options[:dependencies] || []
|
62
67
|
require 'bosh/gen/generators/job_generator'
|
63
|
-
Bosh::Gen::Generators::JobGenerator.start([name,
|
68
|
+
Bosh::Gen::Generators::JobGenerator.start([name, dependencies, 'simple'])
|
64
69
|
end
|
65
70
|
|
66
|
-
desc "template JOB FILE_PATH",
|
71
|
+
desc "template JOB FILE_PATH",
|
72
|
+
"Add a Job template (example FILE_PATH: config/httpd.conf)"
|
67
73
|
def template(job_name, file_path)
|
68
74
|
require 'bosh/gen/generators/job_template_generator'
|
69
75
|
Bosh::Gen::Generators::JobTemplateGenerator.start([job_name, file_path])
|
70
76
|
end
|
71
77
|
|
72
|
-
desc "extract-job
|
73
|
-
|
74
|
-
|
78
|
+
desc "extract-job SOURCE_PACKAGE_PATH",
|
79
|
+
"Extracts a job from another release and all its " +
|
80
|
+
"dependent packages and source"
|
81
|
+
def extract_job(source_package_path)
|
82
|
+
source_package_path = File.expand_path(source_package_path)
|
75
83
|
require 'bosh/gen/generators/extract_job_generator'
|
76
|
-
Bosh::Gen::Generators::ExtractJobGenerator.start([
|
84
|
+
Bosh::Gen::Generators::ExtractJobGenerator.start([source_package_path])
|
77
85
|
end
|
78
86
|
|
79
|
-
desc "extract-pkg
|
80
|
-
|
87
|
+
desc "extract-pkg SOURCE_PACKAGE_PATH",
|
88
|
+
"Extracts a package from another release and all its " +
|
89
|
+
"dependent packages and sources"
|
90
|
+
def extract_pkg(source_package_path)
|
91
|
+
source_package_path = File.expand_path(source_package_path)
|
81
92
|
require 'bosh/gen/generators/extract_package_generator'
|
82
|
-
Bosh::Gen::Generators::ExtractPackageGenerator.start([
|
93
|
+
Bosh::Gen::Generators::ExtractPackageGenerator.start([source_package_path])
|
83
94
|
end
|
84
95
|
|
85
|
-
desc "manifest NAME PATH
|
86
|
-
|
87
|
-
method_option :
|
88
|
-
|
89
|
-
|
96
|
+
desc "manifest NAME PATH",
|
97
|
+
"Creates a deployment manifest based on the release located at PATH"
|
98
|
+
method_option :force, :type => :boolean,
|
99
|
+
:desc => "Force override existing target manifest file"
|
100
|
+
method_option :addresses, :aliases => ['-a'], :type => :array,
|
101
|
+
:desc => "List of IP addresses available for jobs"
|
102
|
+
method_option :disk, :aliases => ['-d'], :type => :string,
|
103
|
+
:desc => "Attach persistent disks to VMs of specific size, e.g. 8196"
|
104
|
+
def manifest(name, release_path)
|
90
105
|
release_path = File.expand_path(release_path)
|
91
106
|
ip_addresses = options["addresses"] || []
|
92
107
|
flags = { :force => options["force"] || false, :disk => options[:disk] }
|
93
108
|
require 'bosh/gen/generators/deployment_manifest_generator'
|
94
|
-
Bosh::Gen::Generators::DeploymentManifestGenerator.start(
|
109
|
+
Bosh::Gen::Generators::DeploymentManifestGenerator.start(
|
110
|
+
[name, release_path, ip_addresses, flags])
|
95
111
|
end
|
96
112
|
|
97
113
|
no_tasks do
|
@@ -8,7 +8,6 @@ module Bosh::Gen
|
|
8
8
|
|
9
9
|
argument :name
|
10
10
|
argument :release_path
|
11
|
-
argument :director_uuid
|
12
11
|
argument :ip_addresses
|
13
12
|
argument :flags, :type => :hash
|
14
13
|
|
@@ -31,10 +30,15 @@ module Bosh::Gen
|
|
31
30
|
|
32
31
|
# Create a deployment manifest (initially for AWS only)
|
33
32
|
def create_deployment_manifest
|
34
|
-
cloud_properties = {
|
33
|
+
cloud_properties = {
|
34
|
+
"instance_type" => "m1.small",
|
35
|
+
"availability_zone" => "us-east-1e"
|
36
|
+
}
|
35
37
|
cloud_properties["persistent_disk"] = flags[:disk] if flags[:disk]
|
36
38
|
cloud_properties["static_ips"] = ip_addresses
|
37
|
-
|
39
|
+
director_uuid = Bosh::Gen::Models::BoshConfig.new.target_uuid
|
40
|
+
manifest = Bosh::Gen::Models::DeploymentManifest.new(
|
41
|
+
name, director_uuid, release_properties, cloud_properties)
|
38
42
|
manifest.jobs = job_manifests
|
39
43
|
create_file manifest_file_name, manifest.to_yaml, :force => flags[:force]
|
40
44
|
end
|
@@ -6,22 +6,41 @@ module Bosh::Gen
|
|
6
6
|
class ExtractJobGenerator < Thor::Group
|
7
7
|
include Thor::Actions
|
8
8
|
|
9
|
-
argument :
|
10
|
-
|
11
|
-
argument :job_name
|
12
|
-
|
9
|
+
argument :source_job_path
|
10
|
+
|
13
11
|
def check_root_is_release
|
14
12
|
unless File.exist?("jobs") && File.exist?("packages")
|
15
13
|
raise Thor::Error.new("run inside a BOSH release project")
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
17
|
+
def check_job_path_is_valid
|
18
|
+
unless File.exist?(source_job_path)
|
19
|
+
raise Thor::Error.new("source job path does not exist")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_job_path_is_a_job
|
24
|
+
parent_dir = File.basename(File.dirname(source_job_path))
|
25
|
+
unless parent_dir == "jobs"
|
26
|
+
raise Thor::Error.new("source jobs path is not a BOSH job")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def check_job_path_within_release
|
31
|
+
FileUtils.chdir(source_release_path) do
|
32
|
+
unless File.exist?("jobs") && File.exist?("packages")
|
33
|
+
raise Thor::Error.new("source job path is not within a BOSH release project")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
19
38
|
def using_source_release_for_templates
|
20
39
|
source_paths << File.join(source_release_path)
|
21
40
|
end
|
22
41
|
|
23
42
|
def copy_job_dir
|
24
|
-
directory "jobs/#{source_job_name}", "jobs/#{
|
43
|
+
directory "jobs/#{source_job_name}", "jobs/#{target_job_name}"
|
25
44
|
end
|
26
45
|
|
27
46
|
def detect_dependent_packages
|
@@ -56,8 +75,20 @@ module Bosh::Gen
|
|
56
75
|
end
|
57
76
|
|
58
77
|
private
|
78
|
+
def source_release_path
|
79
|
+
File.expand_path(File.join(source_job_path, "..", ".."))
|
80
|
+
end
|
81
|
+
|
82
|
+
def source_job_name
|
83
|
+
File.basename(source_job_path)
|
84
|
+
end
|
85
|
+
|
86
|
+
def target_job_name
|
87
|
+
source_job_name
|
88
|
+
end
|
89
|
+
|
59
90
|
def job_dir(path="")
|
60
|
-
File.join("jobs",
|
91
|
+
File.join("jobs", target_job_name, path)
|
61
92
|
end
|
62
93
|
|
63
94
|
def source_file(*path)
|
@@ -6,8 +6,7 @@ module Bosh::Gen
|
|
6
6
|
class ExtractPackageGenerator < Thor::Group
|
7
7
|
include Thor::Actions
|
8
8
|
|
9
|
-
argument :
|
10
|
-
argument :source_package_name
|
9
|
+
argument :source_package_path
|
11
10
|
|
12
11
|
def check_root_is_release
|
13
12
|
unless File.exist?("jobs") && File.exist?("packages")
|
@@ -15,6 +14,21 @@ module Bosh::Gen
|
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
17
|
+
def check_package_path_within_release
|
18
|
+
FileUtils.chdir(source_release_path) do
|
19
|
+
unless File.exist?("jobs") && File.exist?("packages")
|
20
|
+
raise Thor::Error.new("source package path is not within a BOSH release project")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_package_path_is_a_package
|
26
|
+
parent_dir = File.basename(File.dirname(source_package_path))
|
27
|
+
unless parent_dir == "packages"
|
28
|
+
raise Thor::Error.new("source package path is not a BOSH package")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
18
32
|
def using_source_release_for_templates
|
19
33
|
source_paths << File.join(source_release_path)
|
20
34
|
end
|
@@ -22,7 +36,7 @@ module Bosh::Gen
|
|
22
36
|
# Extract target package and all its dependencies
|
23
37
|
def detect_dependent_packages
|
24
38
|
spec = YAML.load_file(source_package_dir("spec"))
|
25
|
-
@packages = [
|
39
|
+
@packages = [source_package_name]
|
26
40
|
@packages << spec["packages"] if spec["packages"]
|
27
41
|
end
|
28
42
|
|
@@ -54,8 +68,12 @@ module Bosh::Gen
|
|
54
68
|
end
|
55
69
|
|
56
70
|
private
|
57
|
-
def
|
58
|
-
|
71
|
+
def source_release_path
|
72
|
+
File.expand_path(File.join(source_package_path, "..", ".."))
|
73
|
+
end
|
74
|
+
|
75
|
+
def source_package_name
|
76
|
+
File.basename(source_package_path)
|
59
77
|
end
|
60
78
|
|
61
79
|
def package_dir(path="")
|
@@ -7,9 +7,8 @@ module Bosh::Gen
|
|
7
7
|
include Thor::Actions
|
8
8
|
|
9
9
|
argument :job_name
|
10
|
-
argument :command
|
11
10
|
argument :dependencies, :type => :array
|
12
|
-
argument :
|
11
|
+
argument :purpose
|
13
12
|
|
14
13
|
def self.source_root
|
15
14
|
File.join(File.dirname(__FILE__), "job_generator", "templates")
|
@@ -22,29 +21,44 @@ module Bosh::Gen
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def check_name
|
25
|
-
raise Thor::Error.new("'#{job_name}' is not a
|
24
|
+
raise Thor::Error.new("'#{job_name}' is not a valid BOSH id") unless job_name.bosh_valid_id?
|
26
25
|
end
|
27
|
-
|
26
|
+
|
27
|
+
def check_purpose
|
28
|
+
unless valid_purposes.include?(purpose)
|
29
|
+
raise Thor::Error.new("'#{purpose}' is not a valid job purpose of #{valid_purposes.inspect}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
28
33
|
def warn_missing_dependencies
|
29
34
|
dependencies.each do |d|
|
30
|
-
raise Thor::Error.new("dependency '#{d}' is not a
|
35
|
+
raise Thor::Error.new("dependency '#{d}' is not a valid BOSH id") unless d.bosh_valid_id?
|
31
36
|
unless File.exist?(File.join("packages", d))
|
32
37
|
say_status "warning", "missing dependency '#{d}'", :yellow
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
42
|
+
# copy the thor template files into the bosh release to be bosh templates
|
43
|
+
# that's right, templates (.tt) can become templates (.erb)
|
37
44
|
def template_files
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
generator_job_templates_path = File.join(self.class.source_root, "jobs/%job_name%_#{purpose}")
|
46
|
+
directory "jobs/%job_name%_#{purpose}", "jobs/#{job_name}"
|
47
|
+
|
48
|
+
# build a hash of { 'bin/webapp_ctl.erb' => 'bin/webapp_ctl', ...} used in spec
|
49
|
+
# TODO: do I need to flatten it to { 'webapp_ctl' => 'bin/webapp_ctl' }?
|
50
|
+
@template_files = {}
|
51
|
+
FileUtils.chdir(File.join(generator_job_templates_path, "templates")) do
|
52
|
+
`ls */*`.split("\n").each do |template_file|
|
53
|
+
# clean up thor name convention
|
54
|
+
template_file.gsub!("%job_name%", job_name)
|
55
|
+
template_file.gsub!(".tt", "")
|
56
|
+
# strip erb from target file
|
57
|
+
target_template_file = template_file.gsub(/.erb/, '')
|
58
|
+
|
59
|
+
@template_files[template_file] = target_template_file
|
60
|
+
end
|
42
61
|
end
|
43
|
-
@template_files = { "#{job_name}_ctl" => "bin/#{job_name}_ctl" }
|
44
|
-
end
|
45
|
-
|
46
|
-
def ctl_executable
|
47
|
-
chmod "jobs/#{job_name}/templates/#{job_name}_ctl", 0755
|
48
62
|
end
|
49
63
|
|
50
64
|
def job_specification
|
@@ -52,6 +66,10 @@ module Bosh::Gen
|
|
52
66
|
create_file job_dir("spec"), YAML.dump(config)
|
53
67
|
end
|
54
68
|
|
69
|
+
def example
|
70
|
+
directory "examples/%job_name%_#{purpose}"
|
71
|
+
end
|
72
|
+
|
55
73
|
private
|
56
74
|
def filenames
|
57
75
|
files.map {|f| File.basename(f) }
|
@@ -61,8 +79,8 @@ module Bosh::Gen
|
|
61
79
|
File.join("jobs", job_name, path)
|
62
80
|
end
|
63
81
|
|
64
|
-
def
|
65
|
-
|
82
|
+
def valid_purposes
|
83
|
+
%w[simple]
|
66
84
|
end
|
67
85
|
|
68
86
|
# Run a command in git.
|
@@ -0,0 +1,13 @@
|
|
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 %>_rack_ctl start'"
|
4
|
+
stop program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger <%= job_name %>_ctl '/var/vcap/jobs/<%= job_name %>/bin/<%= job_name %>_rack_ctl stop'"
|
5
|
+
group vcap
|
6
|
+
|
7
|
+
<%% if properties.<%= job_name %> && properties.<%= job_name %>.use_nginx %>
|
8
|
+
check process nginx
|
9
|
+
with pidfile /var/vcap/sys/run/<%= job_name %>/nginx.pid
|
10
|
+
start program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger nginx_ctl '/var/vcap/jobs/<%= job_name %>/bin/nginx_ctl start'"
|
11
|
+
stop program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger nginx_ctl '/var/vcap/jobs/<%= job_name %>/bin/nginx_ctl stop'"
|
12
|
+
group vcap
|
13
|
+
<%% end %>
|
@@ -0,0 +1,59 @@
|
|
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 %>/bin/ctl_setup.sh
|
8
|
+
|
9
|
+
export PORT=${PORT:-5000}
|
10
|
+
export LANG=en_US.UTF-8
|
11
|
+
|
12
|
+
# Setup HTTP_PROXY, HTTPS_PROXY, NO_PROXY as necessary
|
13
|
+
source $JOB_DIR/bin/ctl_nginx.sh
|
14
|
+
|
15
|
+
# Setup for Rails application
|
16
|
+
source $JOB_DIR/bin/rails_ctl_setup.sh
|
17
|
+
|
18
|
+
# Helpers for PostgresDB
|
19
|
+
source $JOB_DIR/bin/ctl_db_utils.sh
|
20
|
+
|
21
|
+
# Helpers for Redis
|
22
|
+
source $JOB_DIR/bin/ctl_redis_utils.sh
|
23
|
+
|
24
|
+
case $1 in
|
25
|
+
|
26
|
+
start)
|
27
|
+
pid_guard $PIDFILE $JOB_NAME
|
28
|
+
|
29
|
+
cd $WEBAPP_DIR
|
30
|
+
|
31
|
+
# link database.yml config to application
|
32
|
+
link_sql_db_config
|
33
|
+
|
34
|
+
# if redis enabled, link it to application
|
35
|
+
link_redis_config yaml config/redis.yml
|
36
|
+
|
37
|
+
# Migrations, if requested
|
38
|
+
run_migrations $WEBAPP_DIR
|
39
|
+
|
40
|
+
# TODO what is 'ulimit -c unlimited' for; when not to use it?
|
41
|
+
ulimit -c unlimited
|
42
|
+
|
43
|
+
# Start the rack app using requested appstack
|
44
|
+
source $JOB_DIR/bin/ctl_start.sh
|
45
|
+
|
46
|
+
echo "Running $JOB_NAME on $PORT"
|
47
|
+
;;
|
48
|
+
|
49
|
+
stop)
|
50
|
+
kill_and_wait $PIDFILE
|
51
|
+
|
52
|
+
;;
|
53
|
+
*)
|
54
|
+
echo "Usage: <%= job_name %>_rack_ctl {start|stop}"
|
55
|
+
|
56
|
+
;;
|
57
|
+
|
58
|
+
esac
|
59
|
+
exit 0
|