server_launcher 1.0.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/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ .DS_Store
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ server_launcher
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="build" taksId="build" /><RakeTask description="" fullCmd="release" taksId="release" /></RakeGroup></Settings>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CssXFireSettings">
4
+ <general autoClear="false" autoExpand="false" />
5
+ <strategy useRoutes="false" mediaReduce="false" fileReduce="false" currentDocumentsReduce="false" resolveVariables="true" resolveMixins="true" />
6
+ <routes />
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectResources">
4
+ <default-html-doctype>$APPLICATION_HOME_DIR$/lib/rubymine.jar!/resources/html5-schema/html5.rnc</default-html-doctype>
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p194 [server_launcher]" project-jdk-type="RUBY_SDK" />
7
+ </project>
8
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/server_launcher.iml" filepath="$PROJECT_DIR$/.idea/server_launcher.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.1.3, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
8
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.3, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
9
+ <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.0.0, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="meta_methods (v1.0.2, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="mocha (v0.10.3, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v2.9.0, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.9.0, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.9.1, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.9.0, RVM: ruby-1.9.3-p194 [server_launcher]) [gem]" level="application" />
18
+ </component>
19
+ </module>
20
+
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/.rvmrc ADDED
@@ -0,0 +1,4 @@
1
+ rvm_gemset_create_on_use_flag=1
2
+ rvm_pretty_print_flag=1
3
+
4
+ rvm use 1.9.3@server_launcher
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source :rubygems
2
+
3
+ group :default do
4
+ gem "meta_methods"
5
+ end
6
+
7
+ group :development do
8
+ gem "gemspec_deps_gen"
9
+ gem "gemcutter"
10
+ end
11
+
12
+ group :test do
13
+ gem "rspec", "2.9.0"
14
+ gem "mocha", "0.10.3"
15
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alexander Shvets
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.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ server_launcher
2
+ ===============
3
+
4
+ Convenient classes to manage servers from rake
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+
3
+ $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
4
+
5
+ require "rspec/core/rake_task"
6
+ require "server_launcher/version"
7
+ require "gemspec_deps_gen/gemspec_deps_gen"
8
+
9
+ def version
10
+ ServerLauncher::VERSION
11
+ end
12
+
13
+ def project_name
14
+ File.basename(Dir.pwd)
15
+ end
16
+
17
+ task :build do
18
+ generator = GemspecDepsGen.new
19
+
20
+ generator.generate_dependencies "#{project_name}.gemspec.erb", "#{project_name}.gemspec"
21
+
22
+ system "gem build #{project_name}.gemspec"
23
+ end
24
+
25
+ task :release => :build do
26
+ system "gem push #{project_name}-#{version}.gem"
27
+ end
28
+
29
+ RSpec::Core::RakeTask.new do |task|
30
+ task.pattern = 'spec/**/*_spec.rb'
31
+ task.verbose = false
32
+ end
@@ -0,0 +1,36 @@
1
+ require 'server_launcher/server'
2
+
3
+ class JBossServer < Server
4
+ def fix
5
+ "chmod +x #{app_server_home}/bin/*.sh"
6
+ end
7
+
8
+ def clean
9
+ "rm -rf #{deploy_dir}/#{project_name}.war"
10
+ end
11
+
12
+ def stop
13
+ # #puts `#{app_server_home}/bin/jboss-admin.sh --connect command=:shutdown`
14
+ "#{app_server_home}/bin/shutdown.sh -S"
15
+ end
16
+
17
+ def start
18
+ #"LAUNCH_JBOSS_IN_BACKGROUND=true #{app_server_home}/bin/standalone.sh"
19
+
20
+ ENV['JAVA_OPTS'] = '-server -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m'
21
+
22
+ "#{app_server_home}/bin/run.sh > #{logfile} 2>&1 &"
23
+ end
24
+
25
+ def deploy
26
+ result = ["cp #{warfile} #{deploy_dir}/#{project_name}.war"]
27
+
28
+ result << "cp #{datasource_file_name} #{deploy_dir}/#{File.basename(datasource_file_name)}" if
29
+ respond_to? :datasource_file_name
30
+
31
+ result
32
+ end
33
+
34
+ end
35
+
36
+
@@ -0,0 +1,46 @@
1
+ require 'meta_methods'
2
+
3
+ class Server
4
+ include MetaMethods
5
+
6
+ def initialize params
7
+ define_attributes(:attr_reader, self, params, false)
8
+ end
9
+
10
+ def execute method_name
11
+ puts "Target: '#{method_name}'."
12
+
13
+ method = self.class.instance_method(method_name)
14
+
15
+ result = method.bind(self).call()
16
+
17
+ if result.kind_of? String
18
+ commands = [result]
19
+ else
20
+ commands = result
21
+ end
22
+
23
+ commands.each do |command|
24
+ puts "Executing '#{command}'..."
25
+
26
+ execute_command(command)
27
+ end
28
+ end
29
+
30
+ def execute_command(command)
31
+ output = nil
32
+ error = nil
33
+ status = nil
34
+
35
+ Open3.popen3(command) do |_, stdout, stderr|
36
+ output = stdout.readlines
37
+ error = stderr.readlines
38
+ status = $?
39
+ end
40
+
41
+ puts "Output:\n #{output}" if output && output.size > 0
42
+ puts "Error: #{error}" if error && error.size > 0
43
+ puts "Status: #{status}" if status && status.to_s.to_i > 0
44
+ end
45
+
46
+ end
@@ -0,0 +1,28 @@
1
+ require 'server_launcher/server'
2
+
3
+ class TomcatServer < Server
4
+ def fix
5
+ "chmod +x #{app_server_home}/bin/*.sh"
6
+ end
7
+
8
+ def clean
9
+ ["rm -rf #{deploy_dir}/#{project_name}*",
10
+ "rm -f #{deploy_dir}/#{project_name}.war"]
11
+ end
12
+
13
+ def start
14
+ ENV['JAVA_OPTS'] = '-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m'
15
+
16
+ "#{app_server_home}/bin/startup.sh"
17
+ end
18
+
19
+ def stop
20
+ "#{app_server_home}/bin/shutdown.sh"
21
+ end
22
+
23
+ def deploy
24
+ "cp #{warfile} #{deploy_dir}/#{project_name}.war"
25
+ end
26
+ end
27
+
28
+
@@ -0,0 +1,3 @@
1
+ module ServerLauncher
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'server_launcher/server'
2
+
3
+ class WinstoneServer < Server
4
+
5
+ def start
6
+ "winstone --httpPort=#{port} --controlPort=#{control_port} --useSavedSessions --warfile=#{warfile} > #{logfile}
7
+ 2>&1 &"
8
+ end
9
+
10
+ def start_exploded
11
+ "winstone --httpPort=#{port} --controlPort=#{control_port} --useSavedSessions --webroot=#{webroot} > #{logfile}
12
+ 2>&1"
13
+ end
14
+
15
+ def stop
16
+ "winstone tool winstone.tools.WinstoneControl shutdown --host=#{host_name} --port=#{control_port}"
17
+ end
18
+
19
+ def reload
20
+ "winstone tool winstone.tools.WinstoneControl reload: --host=#{host_name} --port=#{control_port}"
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ require 'server_launcher/jboss_server'
2
+ require 'server_launcher/tomcat_server'
3
+ require 'server_launcher/winstone_server'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/lib/server_launcher/version')
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "server_launcher"
7
+ spec.summary = %q{Convenient classes to manage servers from rake}
8
+ spec.description = %q{Convenient classes to manage servers from rake}
9
+ spec.email = "alexander.shvets@gmail.com"
10
+ spec.authors = ["Alexander Shvets"]
11
+ spec.homepage = "http://github.com/shvets/server_launcher"
12
+
13
+ spec.files = `git ls-files`.split($\)
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+ spec.version = ServerLauncher::VERSION
17
+
18
+ <%= include_dependencies %>
19
+ end
20
+
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'server_launcher/jboss_server'
4
+
5
+ describe JBossServer do
6
+
7
+ before do
8
+ jboss_version = "6.1.0.Final"
9
+ app_server_home = "#{ENV['HOME']}/jboss-#{jboss_version}"
10
+ deploy_dir = "#{app_server_home}/server/default/deploy"
11
+
12
+ project_name = "test"
13
+ warfile = "build/#{project_name}.war"
14
+
15
+ logfile = "#{app_server_home}/server/default/log/server.log"
16
+
17
+ @server = JBossServer.new(:app_server_home => app_server_home, :deploy_dir => deploy_dir,
18
+ :project_name => project_name, :warfile => warfile, :logfile => logfile)
19
+ end
20
+
21
+ it "should build fix command" do
22
+ @server.fix.should =~ /chmod \+x/
23
+ end
24
+
25
+ it "should build clean command" do
26
+ @server.clean.should =~ /rm -rf /
27
+ end
28
+
29
+ it "should build stop command" do
30
+ @server.stop.should =~ /shutdown.sh -S/
31
+ end
32
+
33
+ it "should build start command" do
34
+ @server.start.should =~ /bin\/run.sh/
35
+ end
36
+
37
+ it "should build deploy command" do
38
+ @server.deploy.first.should =~ /cp\s/
39
+ end
40
+ end
41
+
42
+
@@ -0,0 +1 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'server_launcher/tomcat_server'
4
+
5
+ describe TomcatServer do
6
+
7
+ before do
8
+ tomcat_version = "7.0.27"
9
+ app_server_home = "/usr/local/Cellar/tomcat/#{tomcat_version}/libexec"
10
+ deploy_dir = "#{app_server_home}/webapps"
11
+
12
+ project_name = "test"
13
+ warfile = "build/#{project_name}.war"
14
+
15
+ logfile = "#{app_server_home}/logs/test-app.log"
16
+
17
+ @server = TomcatServer.new(:app_server_home => app_server_home, :deploy_dir => deploy_dir,
18
+ :project_name => project_name, :warfile => warfile, :logfile => logfile)
19
+ end
20
+
21
+ it "should build fix command" do
22
+ @server.fix.should =~ /chmod \+x/
23
+ end
24
+
25
+ it "should build clean command" do
26
+ @server.clean.first.should =~ /rm -rf /
27
+ end
28
+
29
+ it "should build stop command" do
30
+ @server.stop.should =~ /shutdown.sh/
31
+ end
32
+
33
+ it "should build start command" do
34
+ @server.start.should =~ /bin\/startup.sh/
35
+ end
36
+
37
+ it "should build deploy command" do
38
+ @server.deploy.should =~ /cp\s/
39
+ end
40
+ end
41
+
42
+
@@ -0,0 +1,38 @@
1
+
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+
4
+ require 'server_launcher/winstone_server'
5
+
6
+ describe WinstoneServer do
7
+
8
+ before do
9
+ host_name = ENV['HOST_NAME'] || "localhost"
10
+ port = ENV['PORT'] || "3002"
11
+ control_port = ENV['CONTROL_PORT'] || "3000"
12
+ webroot = "build/exploded"
13
+
14
+ project_name = "test"
15
+ warfile = "build/#{project_name}.war"
16
+
17
+ logfile = "logs/test-app.log"
18
+
19
+ @server = WinstoneServer.new(:host_name => host_name, :port => port, :control_port => control_port,
20
+ :webroot => webroot, :warfile => warfile, :logfile => logfile)
21
+ end
22
+
23
+ it "should build stop command" do
24
+ @server.stop.should =~ /winstone tool winstone.tools.WinstoneControl shutdown/
25
+ end
26
+
27
+ it "should build start command" do
28
+ @server.start.should =~ /--warfile=build\/test.war/
29
+ end
30
+
31
+ it "should build start_exploded command" do
32
+ @server.start_exploded.should =~ /--webroot=build\/exploded/
33
+ end
34
+
35
+ it "should build reload command" do
36
+ @server.reload.should =~ /reload: --host=localhost/
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: server_launcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Shvets
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: meta_methods
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: gemspec_deps_gen
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: gemcutter
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Convenient classes to manage servers from rake
63
+ email: alexander.shvets@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - .gitignore
69
+ - .idea/.name
70
+ - .idea/.rakeTasks
71
+ - .idea/cssxfire.xml
72
+ - .idea/encodings.xml
73
+ - .idea/misc.xml
74
+ - .idea/modules.xml
75
+ - .idea/scopes/scope_settings.xml
76
+ - .idea/server_launcher.iml
77
+ - .idea/vcs.xml
78
+ - .rvmrc
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - lib/server_launcher.rb
84
+ - lib/server_launcher/jboss_server.rb
85
+ - lib/server_launcher/server.rb
86
+ - lib/server_launcher/tomcat_server.rb
87
+ - lib/server_launcher/version.rb
88
+ - lib/server_launcher/winstone_server.rb
89
+ - server_launcher.gemspec.erb
90
+ - spec/jboss_server_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/tomcat_server_spec.rb
93
+ - spec/winstone_server_spec.rb
94
+ homepage: http://github.com/shvets/server_launcher
95
+ licenses: []
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 1.8.23
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Convenient classes to manage servers from rake
118
+ test_files:
119
+ - spec/jboss_server_spec.rb
120
+ - spec/spec_helper.rb
121
+ - spec/tomcat_server_spec.rb
122
+ - spec/winstone_server_spec.rb