foreman-upstart-daemon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
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
18
+
19
+ .idea
20
+ .idea/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in foreman-upstart-daemon.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Elisheva Kantor , Zohar Arad
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Foreman::Upstart::Daemon
2
+
3
+ ##Introduction
4
+
5
+ Foreman export the application in upstart-daemon format
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'foreman-upstart-daemon'
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install foreman-upstart-daemon
20
+
21
+ ##Usage
22
+
23
+ $ foreman export upstart-daemon [location]
24
+
25
+ Foreman export your application to [location] path.
26
+
27
+ For example:
28
+
29
+ foreman export upstart-daemon /etc/init
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/foreman-upstart-daemon/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Elisheva Kantor", "Zohar Arad"]
6
+ gem.email = ["kantor@quicklizard.com", "zohar@quicklizard.com"]
7
+ gem.description = %q{Exports upstart-daemon scripts from Foreman}
8
+ gem.summary = %q{An exporter for Foreman - export the application to upstart as daemon}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "foreman-upstart-daemon"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Foreman::Upstart::Daemon::VERSION
17
+ end
@@ -0,0 +1,5 @@
1
+ require "foreman-upstart-daemon/version"
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ require 'foreman/export/upstart_daemon'
@@ -0,0 +1,7 @@
1
+ module Foreman
2
+ module Upstart
3
+ module Daemon
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ start on runlevel [2345]
2
+ stop on runlevel [06]
3
+
4
+ pre-start script
5
+
6
+ bash << "EOF"
7
+ mkdir -p <%= log_root %>
8
+ chown -R <%= user %> <%= log_root %>
9
+ EOF
10
+
11
+ end script
@@ -0,0 +1,22 @@
1
+ start on starting <%= app %>-<%= process.name %>
2
+ stop on stopping <%= app %>-<%= process.name %>
3
+
4
+ respawn
5
+ kill timeout 10
6
+
7
+ chdir <%= engine.directory %>
8
+ env PORT=<%= port %>
9
+ <% engine.environment.each_pair do |var,env| %>
10
+ env <%= var.upcase %>=<%= env %>
11
+ <% end %>
12
+
13
+ script
14
+ <%
15
+ m = process.command.match /(\S+)\s(.*)/
16
+ cmd, args = m[1], m[2]
17
+ cmd = `which bundle`.strip.gsub(/[\n\r\t]+/,'') if cmd.strip == 'bundle'
18
+ %>
19
+ exec start-stop-daemon -S -u <%= user %> -d <%= engine.directory %> \
20
+ --exec <%= cmd %> \
21
+ -- <%= args %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1
22
+ end script
@@ -0,0 +1,2 @@
1
+ start on starting <%= app %>
2
+ stop on stopping <%= app %>
@@ -0,0 +1,41 @@
1
+ require "erb"
2
+ require "foreman/export"
3
+
4
+ class Foreman::Export::UpstartDaemon < Foreman::Export::Base
5
+
6
+ def export
7
+ error("Must specify a location") unless location
8
+
9
+ FileUtils.mkdir_p location
10
+
11
+ app = self.app || File.basename(engine.directory)
12
+ user = self.user || app
13
+ log_root = self.log || "/var/log/#{app}"
14
+ template_root = File.join(File.dirname(__FILE__),'../data/templates')
15
+
16
+ Dir["#{location}/#{app}*.conf"].each do |file|
17
+ say "cleaning up: #{file}"
18
+ FileUtils.rm(file)
19
+ end
20
+
21
+ master_template = File.join(template_root,'upstart_daemon','master.conf.erb')
22
+ master_config = ERB.new(File.read(master_template)).result(binding)
23
+ write_file "#{location}/#{app}.conf", master_config
24
+
25
+ process_template = File.join(template_root,'upstart_daemon','process.conf.erb')
26
+
27
+ engine.procfile.entries.each do |process|
28
+ next if (conc = self.concurrency[process.name]) < 1
29
+ process_master_template = File.join(template_root,'upstart_daemon','process_master.conf.erb')
30
+ process_master_config = ERB.new(File.read(process_master_template)).result(binding)
31
+ write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
32
+
33
+ 1.upto(self.concurrency[process.name]) do |num|
34
+ port = engine.port_for(process, num, self.port)
35
+ process_config = ERB.new(File.read(process_template)).result(binding)
36
+ write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
37
+ end
38
+ end
39
+ end
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman-upstart-daemon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Elisheva Kantor
9
+ - Zohar Arad
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-05-30 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: Exports upstart-daemon scripts from Foreman
16
+ email:
17
+ - kantor@quicklizard.com
18
+ - zohar@quicklizard.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - .idea/encodings.xml
25
+ - .idea/foreman-upstart-daemon.iml
26
+ - .idea/misc.xml
27
+ - .idea/modules.xml
28
+ - .idea/scopes/scope_settings.xml
29
+ - .idea/vcs.xml
30
+ - Gemfile
31
+ - LICENSE
32
+ - README.md
33
+ - Rakefile
34
+ - foreman-upstart-daemon.gemspec
35
+ - lib/foreman-upstart-daemon.rb
36
+ - lib/foreman-upstart-daemon/version.rb
37
+ - lib/foreman/data/templates/upstart_daemon/master.conf.erb
38
+ - lib/foreman/data/templates/upstart_daemon/process.conf.erb
39
+ - lib/foreman/data/templates/upstart_daemon/process_master.conf.erb
40
+ - lib/foreman/export/upstart_daemon.rb
41
+ homepage: ''
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.22
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: An exporter for Foreman - export the application to upstart as daemon
65
+ test_files: []