procfile-upstart-exporter 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ Procfile Upstart Exporter
2
+ =========================
3
+
4
+ [![Gem Version](https://fury-badge.herokuapp.com/rb/procfile-upstart-exporter.png)](http://badge.fury.io/rb/procfile-upstart-exporter)
5
+ [![Build Status](https://travis-ci.org/dasdad/procfile-upstart-exporter.png)](https://travis-ci.org/dasdad/procfile-upstart-exporter)
6
+ [![Code Climate](https://codeclimate.com/github/dasdad/procfile-upstart-exporter.png)](https://codeclimate.com/github/dasdad/procfile-upstart-exporter)
7
+ [![Dependency Status](https://gemnasium.com/dasdad/procfile-upstart-exporter.png)](https://gemnasium.com/dasdad/procfile-upstart-exporter)
8
+ [![Coverage Status](https://coveralls.io/repos/dasdad/procfile-upstart-exporter/badge.png)](https://coveralls.io/r/dasdad/procfile-upstart-exporter)
9
+
10
+ Export [Procfile][procfile] entries to [Upstart][upstart] jobs.
11
+
12
+ Y U no [Foreman][foreman]?
13
+ --------------------------
14
+
15
+ I'm aware of [Foreman's][foreman] [exporting capabilities][foreman-export] but
16
+ I find them lacking for the following reasons:
17
+
18
+ 1. Templates have [long stading issues][foreman-upstart-template-issues]. This
19
+ could be solved with custom templates.
20
+ 2. Generated [Upstart][upstart] jobs are placed in the same folder. It would
21
+ be nice to have a structure like the following:
22
+
23
+ ```
24
+ /etc/init
25
+ ├── application
26
+ │   ├── background-workers.conf
27
+ │   └── web.conf
28
+ └── application.conf
29
+ ```
30
+
31
+ This makes it easy to delete the application's job entries and looks good.
32
+ Specific processes could be started/stopped with
33
+ `<action> <application>/<process>`. For example, start the job configured
34
+ in `/etc/init/application/web` with `start application/web`.
35
+ 3. When jobs change their name or are removed, they are never deleted from
36
+ `/etc/init`.
37
+
38
+ [Procfile Upstart Exporter][procfile-upstart-exporter] makes this possible.
39
+
40
+
41
+ Install
42
+ -------
43
+
44
+ [Procfile Upstart Exporter][procfile-upstart-exporter] is a
45
+ [Ruby gem][ruby-gem]. Install it with `gem install procfile-upstart-exporter`.
46
+
47
+ Usage
48
+ -----
49
+
50
+ ### Create [Upstart][upstart] jobs configuration
51
+
52
+ ```console
53
+ # procfile-upstart-exporter export \
54
+ --application <application> \
55
+ --procfile <path-to-procfile> \
56
+ --log <path-to-log> \
57
+ --environment <path-to-dotenv-file> \
58
+ --user <user-to-run-job> \
59
+ --path <path-where-upstart-jobs-will-be-created> \
60
+ --verbose
61
+ ```
62
+
63
+ ### Delete [Upstart][upstart] jobs configuration
64
+
65
+ ```console
66
+ # procfile-upstart-exporter destroy \
67
+ --application <application> \
68
+ --path <path-where-upstart-jobs-are-found> \
69
+ --verbose
70
+ ```
71
+
72
+ License
73
+ -------
74
+
75
+ Copyright © 2013 Das Dad
76
+
77
+ Permission is hereby granted, free of charge, to any person obtaining a copy
78
+ of this software and associated documentation files (the “Software”), to deal
79
+ in the Software without restriction, including without limitation the rights to
80
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
81
+ of the Software, and to permit persons to whom the Software is furnished to do
82
+ so, subject to the following conditions:
83
+
84
+ The above copyright notice and this permission notice shall be included in all
85
+ copies or substantial portions of the Software.
86
+
87
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
93
+ SOFTWARE.
94
+
95
+
96
+ [procfile]: http://ddollar.github.io/foreman/#PROCFILE
97
+ [upstart]: http://upstart.ubuntu.com/
98
+ [foreman]: https://github.com/ddollar/foreman
99
+ [foreman-export]: http://ddollar.github.io/foreman/#EXPORTING
100
+ [foreman-upstart-template-issues]: https://github.com/ddollar/foreman/issues/97
101
+ [procfile-upstart-exporter]: https://github.com/dasdad/procfile-upstart-exporter
102
+ [ruby-gem]: http://rubygems.org/
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/procfile_upstart_exporter/cli'
4
+
5
+ ProcfileUpstartExporter::Cli.start ARGV
@@ -0,0 +1,17 @@
1
+ module ProcfileUpstartExporter
2
+ end
3
+
4
+ require 'fileutils'
5
+ require 'erb'
6
+ require 'logger'
7
+
8
+ require 'values'
9
+
10
+ require_relative 'procfile_upstart_exporter/version'
11
+ require_relative 'procfile_upstart_exporter/logger'
12
+ require_relative 'procfile_upstart_exporter/process'
13
+ require_relative 'procfile_upstart_exporter/procfile_parser'
14
+ require_relative 'procfile_upstart_exporter/environment_parser'
15
+ require_relative 'procfile_upstart_exporter/process_job_renderer'
16
+ require_relative 'procfile_upstart_exporter/creator'
17
+ require_relative 'procfile_upstart_exporter/destroyer'
@@ -0,0 +1,46 @@
1
+ require_relative '../procfile-upstart-exporter'
2
+ require 'thor'
3
+
4
+ class ProcfileUpstartExporter::Cli < Thor
5
+ class_option :verbose, type: :boolean
6
+
7
+ def initialize(*)
8
+ super
9
+ self.creator = ProcfileUpstartExporter::Creator.new
10
+ self.destroyer = ProcfileUpstartExporter::Destroyer.new
11
+ end
12
+
13
+ desc 'create', 'Create Upstart jobs configuration'
14
+ option :application, default: File.basename(Dir.pwd)
15
+ option :procfile, default: 'Procfile'
16
+ option :log, default: '/var/log'
17
+ option :environment, default: '.env'
18
+ option :user, default: 'app'
19
+ option :path, default: '/etc/init'
20
+ def create
21
+ destroy
22
+ creator.create options[:application],
23
+ options[:procfile],
24
+ options[:log],
25
+ options[:environment],
26
+ options[:user],
27
+ options[:path]
28
+ end
29
+
30
+ desc 'destroy', 'Delete Upstart jobs configuration'
31
+ option :application, default: File.basename(Dir.pwd)
32
+ option :path, default: '/etc/init'
33
+ def destroy
34
+ enter_verbose_mode if options[:verbose]
35
+ destroyer.destroy options[:application], options[:path]
36
+ end
37
+
38
+ private
39
+
40
+ attr_accessor :creator
41
+ attr_accessor :destroyer
42
+
43
+ def enter_verbose_mode
44
+ ProcfileUpstartExporter.logger.level = Logger::DEBUG
45
+ end
46
+ end
@@ -0,0 +1,45 @@
1
+ class ProcfileUpstartExporter::Creator
2
+ def initialize(
3
+ procfile_parser = ProcfileUpstartExporter::ProcfileParser.new,
4
+ environment_parser = ProcfileUpstartExporter::EnvironmentParser.new,
5
+ process_job_renderer = ProcfileUpstartExporter::ProcessJobRenderer.new
6
+ )
7
+ self.procfile_parser = procfile_parser
8
+ self.environment_parser = environment_parser
9
+ self.process_job_renderer = process_job_renderer
10
+ end
11
+
12
+ def create(
13
+ application, procfile, log, environment, user, upstart_jobs_path,
14
+ templates_path = File.expand_path('../../../templates', __FILE__)
15
+ )
16
+ ProcfileUpstartExporter.logger.debug 'Starting Upstart jobs creation ' \
17
+ "for `#{ application }'"
18
+ application_template = File.join templates_path, 'application.conf'
19
+ application_job = File.join upstart_jobs_path, "#{ application }.conf"
20
+ application_path = File.join upstart_jobs_path, application
21
+ application_log_path = File.join log, application
22
+
23
+ FileUtils.cp application_template, application_job
24
+ FileUtils.mkdir_p application_path
25
+ FileUtils.mkdir_p application_log_path
26
+ FileUtils.chown user, user, application_log_path
27
+ procfile_parser.parse(procfile).each do |process|
28
+ File.write(
29
+ File.join(application_path, "#{ process.name }.conf"),
30
+ process_job_renderer.render(
31
+ application, user, environment_parser.parse(environment),
32
+ Dir.pwd, log, process
33
+ )
34
+ )
35
+ end
36
+ ProcfileUpstartExporter.logger.debug 'Created Upstart jobs for ' \
37
+ "`#{ application }'"
38
+ end
39
+
40
+ private
41
+
42
+ attr_accessor :procfile_parser
43
+ attr_accessor :environment_parser
44
+ attr_accessor :process_job_renderer
45
+ end
@@ -0,0 +1,12 @@
1
+ class ProcfileUpstartExporter::Destroyer
2
+ def destroy application, path
3
+ ProcfileUpstartExporter.logger.debug 'Starting Upstart jobs deletion'
4
+ "for `#{ application }'"
5
+ stopping_output = IO.popen(['stop', application], err: [:child, :out]).read
6
+ ProcfileUpstartExporter.logger.debug stopping_output
7
+ FileUtils.rm_rf File.join(path, "#{ application }.conf")
8
+ FileUtils.rm_rf File.join(path, application)
9
+ ProcfileUpstartExporter.logger.debug 'Deleted Upstart jobs for ' \
10
+ "`#{ application }'"
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class ProcfileUpstartExporter::EnvironmentParser
2
+ def parse environment
3
+ ProcfileUpstartExporter.logger.debug "Start parsing environment file " \
4
+ "`#{ environment }'"
5
+ if File.exists? environment
6
+ File.read(environment).split("\n")
7
+ else
8
+ ProcfileUpstartExporter.logger.debug "Environment file " \
9
+ "`#{ environment }' does not exist"
10
+ []
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module ProcfileUpstartExporter
2
+ class << self
3
+ attr_writer :logger
4
+
5
+ def logger
6
+ @logger ||= Logger.new(STDOUT).tap do |logger|
7
+ logger.level = defined?(RSpec) ? Logger::FATAL : Logger::INFO
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ ProcfileUpstartExporter::Process = Value.new :name, :command
@@ -0,0 +1,21 @@
1
+ class ProcfileUpstartExporter::ProcessJobRenderer
2
+ attr_reader :template
3
+
4
+ def initialize(
5
+ template = File.read(
6
+ File.expand_path(
7
+ File.join('..', '..', '..', 'templates', 'process.conf.erb'), __FILE__
8
+ )
9
+ )
10
+ )
11
+ @erb = ERB.new template, nil, '-'
12
+ end
13
+
14
+ def render application, user, environment_variables, application_root,
15
+ log, process
16
+ ProcfileUpstartExporter.logger.debug 'Start rendering process job'
17
+ # Double assign to avoid warnings
18
+ home = home = Etc.getpwnam(user).dir
19
+ @erb.result binding
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ class ProcfileUpstartExporter::ProcfileParser
2
+ def parse procfile
3
+ ProcfileUpstartExporter.logger.debug 'Start parsing Procfile ' \
4
+ "`#{ procfile }'"
5
+ File.read(procfile).split("\n").map do |process_line|
6
+ ProcfileUpstartExporter::Process.new(
7
+ *process_line.scan(/\A([^:]+):(.*)\z/).first.map(&:strip)
8
+ )
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ProcfileUpstartExporter
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'procfile_upstart_exporter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'procfile-upstart-exporter'
8
+ spec.version = ProcfileUpstartExporter::VERSION
9
+ spec.authors = ['Das Dad']
10
+ spec.email = ['dev@dasdad.com.br']
11
+ spec.description = %q{Export Procfile entries to Upstart jobs.}
12
+ spec.summary = %q{Solve common problems with `foreman export`}
13
+ spec.homepage = 'https://github.com/dasdad/procfile-upstart-exporter'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'thor'
22
+ spec.add_dependency 'values'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '~> 2.14'
27
+ spec.add_development_dependency 'pry-nav'
28
+ end
@@ -0,0 +1,2 @@
1
+ RAILS_ENV=production
2
+ DATABASE_URL=postgresl://localhost:4567
@@ -0,0 +1,2 @@
1
+ web: bundle exec rails server -p 5000
2
+ background: bundle exec sidekiq
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcfileUpstartExporter::Creator do
4
+ subject(:creator) {
5
+ ProcfileUpstartExporter::Creator.new procfile_parser, environment_parser,
6
+ process_job_renderer
7
+ }
8
+
9
+ let(:procfile_parser) { double }
10
+ let(:environment_parser) { double }
11
+ let(:process_job_renderer) { double }
12
+
13
+ describe '#create' do
14
+ let(:application) { 'application' }
15
+ let(:procfile) { 'Procfile' }
16
+ let(:log) { "#{ temp_dir }/log" }
17
+ let(:application_log) { "#{ log }/#{ application}" }
18
+ let(:environment) { '.env' }
19
+ let(:user) { 'bin' }
20
+ let(:upstart_jobs_path) { temp_dir }
21
+ let(:application_root) {
22
+ File.expand_path 'spec/fixtures/sample-application'
23
+ }
24
+ let(:environment_variables) {
25
+ %w{ RAILS_ENV=production DATABASE_URL=postgresl://localhost:4567 }
26
+ }
27
+ let(:web_process) {
28
+ ProcfileUpstartExporter::Process.with(
29
+ name: 'web',
30
+ command: 'bundle exec rails server -p 5000'
31
+ )
32
+ }
33
+ let(:background_process) {
34
+ ProcfileUpstartExporter::Process.with(
35
+ name: 'background',
36
+ command: 'bundle exec sidekiq'
37
+ )
38
+ }
39
+
40
+ let(:act) {
41
+ Dir.chdir 'spec/fixtures/sample-application' do
42
+ creator.create application, procfile, log, environment, user,
43
+ upstart_jobs_path
44
+ end
45
+ }
46
+
47
+ before do
48
+ allow(procfile_parser).to receive(:parse)
49
+ .and_return [web_process, background_process]
50
+
51
+ allow(environment_parser).to receive(:parse)
52
+ .and_return environment_variables
53
+
54
+ allow(process_job_renderer).to receive(:render)
55
+ .with(application, user, environment_variables, application_root,
56
+ log, web_process)
57
+ .and_return <<-JOB_CONFIGURATION
58
+ env RAILS_ENV=production
59
+ env DATABASE_URL=postgresl://localhost:4567
60
+ exec bundle exec rails server -p 5000
61
+ JOB_CONFIGURATION
62
+
63
+ allow(process_job_renderer).to receive(:render)
64
+ .with(application, user, environment_variables, application_root,
65
+ log, background_process)
66
+ .and_return <<-JOB_CONFIGURATION
67
+ env RAILS_ENV=production
68
+ env DATABASE_URL=postgresl://localhost:4567
69
+ exec bundle exec sidekiq
70
+ JOB_CONFIGURATION
71
+
72
+ allow(FileUtils).to receive(:chown)
73
+ end
74
+
75
+ it 'creates an Upstart job for the application' do
76
+ act
77
+ expect(
78
+ File.exists? "#{ upstart_jobs_path }/#{ application }.conf"
79
+ ).to be_true
80
+ end
81
+
82
+ it 'renders the Upstart job template for each process in Procfile' do
83
+ act
84
+ expect(
85
+ File.read "#{ upstart_jobs_path }/#{ application }/web.conf"
86
+ ).to match 'bundle exec rails server -p 5000'
87
+ expect(
88
+ File.read "#{ upstart_jobs_path }/#{ application }/background.conf"
89
+ ).to match 'bundle exec sidekiq'
90
+ end
91
+
92
+ it 'creates a folder for logging owned by the user' do
93
+ expect(FileUtils).to receive(:chown).with(user, user, application_log)
94
+ act
95
+ expect(File.directory? application_log).to be_true
96
+ end
97
+
98
+ it "places environment variables from `.env' in process' Upstart job" do
99
+ act
100
+ expect(
101
+ File.read("#{ upstart_jobs_path }/#{ application }/background.conf")
102
+ ).to match 'RAILS_ENV=production'
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcfileUpstartExporter::Destroyer do
4
+ subject(:destroyer) { ProcfileUpstartExporter::Destroyer.new }
5
+
6
+ describe '#destroy' do
7
+ let(:application) { 'application' }
8
+ let(:path) { temp_dir }
9
+ let(:application_path) { "#{ path }/#{ application }" }
10
+ let(:application_job) { "#{ path }/#{ application }.conf" }
11
+ let(:process_job) { "#{ path }/#{ application }/web.conf" }
12
+
13
+ let(:act) {
14
+ destroyer.destroy application, path
15
+ }
16
+
17
+ before do
18
+ FileUtils.mkdir_p application_path
19
+ FileUtils.touch application_job
20
+ FileUtils.touch process_job
21
+ allow(Kernel).to receive(:system)
22
+ end
23
+
24
+ it 'stops the jobs' do
25
+ expect(IO).to receive(:popen).with(['stop', application],
26
+ err: [:child, :out]).and_call_original
27
+ act
28
+ end
29
+
30
+ it 'deletes Upstart jobs' do
31
+ act
32
+ [application_path, application_job, process_job].each do |path|
33
+ expect(File.exists? path).to be_false
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcfileUpstartExporter::EnvironmentParser do
4
+ subject(:environment_parser) {
5
+ ProcfileUpstartExporter::EnvironmentParser.new
6
+ }
7
+
8
+ describe '#parse' do
9
+ subject(:environment_variables) { environment_parser.parse environment }
10
+
11
+ let(:environment) { 'spec/fixtures/sample-application/.env' }
12
+
13
+ it 'reads the environment file' do
14
+ expect(File).to receive(:read).with(environment).and_call_original
15
+ subject
16
+ end
17
+
18
+ it 'returns an Array of Strings with environment variables' do
19
+ expect(environment_variables).to eq(
20
+ %w{ RAILS_ENV=production DATABASE_URL=postgresl://localhost:4567 }
21
+ )
22
+ end
23
+
24
+ context 'environment file does not exist' do
25
+ let(:environment) { 'non-existing-file' }
26
+
27
+ it 'returns an empty Array' do
28
+ expect(environment_variables).to eq([])
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcfileUpstartExporter::ProcessJobRenderer do
4
+ subject(:process_job_renderer) {
5
+ ProcfileUpstartExporter::ProcessJobRenderer.new
6
+ }
7
+
8
+ describe '#render' do
9
+ subject(:process_job) {
10
+ process_job_renderer.render application, user, environment_variables,
11
+ application_root, log, process
12
+ }
13
+
14
+ let(:application) { 'application' }
15
+ let(:user) { 'bin' }
16
+ let(:log) { "#{ temp_dir }/log" }
17
+ let(:application_root) {
18
+ File.expand_path 'spec/fixtures/sample-application'
19
+ }
20
+ let(:environment_variables) {
21
+ %w{ RAILS_ENV=production DATABASE_URL=postgresl://localhost:4567 }
22
+ }
23
+ let(:process) {
24
+ ProcfileUpstartExporter::Process.with(
25
+ name: 'web',
26
+ command: 'bundle exec rails server -p 5000'
27
+ )
28
+ }
29
+
30
+ it 'renders the template' do
31
+ expect(process_job).to eq(<<-PROCESS_JOB)
32
+ start on starting application
33
+ stop on stopping application
34
+
35
+ respawn
36
+
37
+ setuid bin
38
+ setgid bin
39
+
40
+ env HOME=/bin
41
+ env RAILS_ENV=production
42
+ env DATABASE_URL=postgresl://localhost:4567
43
+
44
+ chdir #{ application_root }
45
+
46
+ exec bash -lc 'bundle exec rails server -p 5000 >> #{ log }/application/web.log 2>&1'
47
+ PROCESS_JOB
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProcfileUpstartExporter::ProcfileParser do
4
+ subject(:procfile_parser) { ProcfileUpstartExporter::ProcfileParser.new }
5
+
6
+ describe '#parse' do
7
+ subject(:processes) { procfile_parser.parse procfile }
8
+
9
+ let(:procfile) { 'spec/fixtures/sample-application/Procfile' }
10
+
11
+ it 'reads Procfile' do
12
+ expect(File).to receive(:read).with(procfile).and_call_original
13
+ subject
14
+ end
15
+
16
+ it 'returns Processes for each line' do
17
+ expect(processes).to eq([
18
+ ProcfileUpstartExporter::Process.with(
19
+ name: 'web',
20
+ command: 'bundle exec rails server -p 5000'
21
+ ),
22
+ ProcfileUpstartExporter::Process.with(
23
+ name: 'background',
24
+ command: 'bundle exec sidekiq'
25
+ )
26
+ ])
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ require_relative '../lib/procfile-upstart-exporter'
2
+
3
+ require 'fileutils'
4
+ require 'etc'
5
+
6
+ Dir.glob('./spec/support/**/*.rb').each { |file| require file }
7
+
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+
19
+ config.before do
20
+ FileUtils.rm_rf temp_dir
21
+ FileUtils.mkdir temp_dir
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ def temp_dir
2
+ '/tmp/procfile-upstart-exporter'
3
+ end
@@ -0,0 +1,2 @@
1
+ start on runlevel [2345]
2
+ stop on runlevel [016]
@@ -0,0 +1,16 @@
1
+ start on starting <%= application %>
2
+ stop on stopping <%= application %>
3
+
4
+ respawn
5
+
6
+ setuid <%= user %>
7
+ setgid <%= user %>
8
+
9
+ env HOME=<%= home %>
10
+ <%- environment_variables.each do |environment_variable| -%>
11
+ env <%= environment_variable %>
12
+ <% end -%>
13
+
14
+ chdir <%= application_root %>
15
+
16
+ exec bash -lc '<%= process.command %> >> <%= log %>/<%= application %>/<%= process.name %>.log 2>&1'
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: procfile-upstart-exporter
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Das Dad
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-10-17 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thor
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: values
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ hash: 9
58
+ segments:
59
+ - 1
60
+ - 3
61
+ version: "1.3"
62
+ type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rake
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ hash: 31
87
+ segments:
88
+ - 2
89
+ - 14
90
+ version: "2.14"
91
+ type: :development
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: pry-nav
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ type: :development
106
+ version_requirements: *id006
107
+ description: Export Procfile entries to Upstart jobs.
108
+ email:
109
+ - dev@dasdad.com.br
110
+ executables:
111
+ - procfile-upstart-exporter
112
+ extensions: []
113
+
114
+ extra_rdoc_files: []
115
+
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - Gemfile
120
+ - README.md
121
+ - Rakefile
122
+ - bin/procfile-upstart-exporter
123
+ - lib/procfile-upstart-exporter.rb
124
+ - lib/procfile_upstart_exporter/cli.rb
125
+ - lib/procfile_upstart_exporter/creator.rb
126
+ - lib/procfile_upstart_exporter/destroyer.rb
127
+ - lib/procfile_upstart_exporter/environment_parser.rb
128
+ - lib/procfile_upstart_exporter/logger.rb
129
+ - lib/procfile_upstart_exporter/process.rb
130
+ - lib/procfile_upstart_exporter/process_job_renderer.rb
131
+ - lib/procfile_upstart_exporter/procfile_parser.rb
132
+ - lib/procfile_upstart_exporter/version.rb
133
+ - procfile-upstart-exporter.gemspec
134
+ - spec/fixtures/sample-application/.env
135
+ - spec/fixtures/sample-application/Procfile
136
+ - spec/procfile_upstart_exporter/creator_spec.rb
137
+ - spec/procfile_upstart_exporter/destroyer_spec.rb
138
+ - spec/procfile_upstart_exporter/environment_parser_spec.rb
139
+ - spec/procfile_upstart_exporter/process_job_renderer_spec.rb
140
+ - spec/procfile_upstart_exporter/procfile_parser_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/support/temp_dir.rb
143
+ - templates/application.conf
144
+ - templates/process.conf.erb
145
+ has_rdoc: true
146
+ homepage: https://github.com/dasdad/procfile-upstart-exporter
147
+ licenses:
148
+ - MIT
149
+ post_install_message:
150
+ rdoc_options: []
151
+
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: 3
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ requirements: []
173
+
174
+ rubyforge_project:
175
+ rubygems_version: 1.6.2
176
+ signing_key:
177
+ specification_version: 3
178
+ summary: Solve common problems with `foreman export`
179
+ test_files:
180
+ - spec/fixtures/sample-application/.env
181
+ - spec/fixtures/sample-application/Procfile
182
+ - spec/procfile_upstart_exporter/creator_spec.rb
183
+ - spec/procfile_upstart_exporter/destroyer_spec.rb
184
+ - spec/procfile_upstart_exporter/environment_parser_spec.rb
185
+ - spec/procfile_upstart_exporter/process_job_renderer_spec.rb
186
+ - spec/procfile_upstart_exporter/procfile_parser_spec.rb
187
+ - spec/spec_helper.rb
188
+ - spec/support/temp_dir.rb