torquebox-rake-support 1.0.0 → 1.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.
@@ -44,6 +44,20 @@ module TorqueBox
44
44
  ENV['TORQUEBOX_CONF'] || ENV['JBOSS_CONF'] || 'default'
45
45
  end
46
46
 
47
+ # TODO: This is not windows friendly, is it?
48
+ def sys_root
49
+ '/'
50
+ end
51
+
52
+ # Used by upstart and launchd
53
+ def opt_dir
54
+ File.join( sys_root, 'opt' )
55
+ end
56
+
57
+ def opt_torquebox
58
+ File.join( opt_dir, 'torquebox' )
59
+ end
60
+
47
61
  def server_dir
48
62
  File.join("#{jboss_home}","server", "#{jboss_conf}" )
49
63
  end
@@ -82,6 +96,11 @@ module TorqueBox
82
96
  raise "No TorqueBox deployer installed in #{deployers_dir}" if ( matching.empty? )
83
97
  end
84
98
 
99
+ def check_opt_torquebox
100
+ raise "TorqueBox not installed in #{opt_torquebox}" unless ( File.exist?( opt_torquebox ) )
101
+ puts "TorqueBox install OK: #{opt_torquebox}"
102
+ end
103
+
85
104
  def run_command_line
86
105
  cmd = Config::CONFIG['host_os'] =~ /mswin/ ? "bin\\run" : "/bin/sh bin/run.sh"
87
106
  options = ENV['JBOSS_OPTS']
@@ -171,7 +190,7 @@ module TorqueBox
171
190
  File.open( deployment, 'w' ) do |file|
172
191
  YAML.dump( deployment_descriptor, file )
173
192
  end
174
- [name, deploy_dir]
193
+ [name, dest_dir]
175
194
  end
176
195
 
177
196
  def deploy_archive(archive_path = nil, dest_dir = deploy_dir)
@@ -211,6 +230,31 @@ module TorqueBox
211
230
  properties_file
212
231
  end
213
232
 
233
+ # TODO: This is not windows friendly
234
+ def create_symlink
235
+ unless File.exist? opt_dir
236
+ success = true
237
+ if !File.writable?( sys_root )
238
+ puts "Cannot write to #{sys_root}. Please ensure #{opt_torquebox} points to your torquebox installation."
239
+ success = false
240
+ else
241
+ puts "Creating #{opt_dir}"
242
+ Dir.new( opt_dir )
243
+ end
244
+ end
245
+
246
+ unless File.exist?( opt_torquebox )
247
+ if File.writable?( opt_dir )
248
+ puts "Linking #{opt_torquebox} to #{torquebox_home}"
249
+ File.symlink( torquebox_home, opt_torquebox )
250
+ else
251
+ puts "Cannot link #{opt_torquebox} to #{torquebox_home}"
252
+ success = false
253
+ end
254
+ end
255
+ success
256
+ end
257
+
214
258
  def exec_command(cmd)
215
259
  IO.popen4( cmd ) do |pid, stdin, stdout, stderr|
216
260
  stdin.close
@@ -0,0 +1,41 @@
1
+ # Copyright 2011 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+
19
+ # Helpers for upstart rake tasks
20
+
21
+ require 'torquebox/deploy_utils'
22
+
23
+ module TorqueBox
24
+ module Launchd
25
+ class << self
26
+
27
+ def plist_dir
28
+ # TODO
29
+ end
30
+
31
+ def check_install
32
+ TorqueBox::DeployUtils.check_opt_torquebox
33
+ # raise "#{init_torquebox} not installed in #{init_dir}" unless ( File.exist?( init_torquebox ) )
34
+ # puts "TorqueBox init scripts OK: #{init_torquebox}"
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+
@@ -21,7 +21,7 @@ require 'torquebox/deploy_utils'
21
21
  namespace :torquebox do
22
22
 
23
23
  desc "Deploy the app in the current directory"
24
- task :deploy, :context_path, :needs =>['torquebox:check'] do |t, args|
24
+ task :deploy, [:context_path] => ['torquebox:check'] do |t, args|
25
25
  descriptor = TorqueBox::DeployUtils.basic_deployment_descriptor( :context_path => args[:context_path] )
26
26
  deployment_name, deploy_dir = TorqueBox::DeployUtils.deploy_yaml( descriptor )
27
27
 
@@ -17,6 +17,9 @@
17
17
 
18
18
  require 'rake'
19
19
  require 'torquebox/deploy_utils'
20
+ require 'torquebox/upstart'
21
+ require 'torquebox/launchd'
22
+
20
23
 
21
24
  namespace :torquebox do
22
25
  desc "Check your installation of the TorqueBox server"
@@ -31,4 +34,67 @@ namespace :torquebox do
31
34
  TorqueBox::DeployUtils.run_server
32
35
  end
33
36
 
37
+ namespace :launchd do
38
+ # desc "Check if TorqueBox is installed as a launchd daemon"
39
+ task :check=>[ 'torquebox:check' ] do
40
+ TorqueBox::Launchd.check_install
41
+ puts "Launchd tasks not done yet. Try again with a later build."
42
+ end
43
+
44
+ # desc "Install TorqueBox as an launchd daemon"
45
+ task :install=>[ 'torquebox:check' ] do
46
+ TorqueBox::DeployUtils.create_symlink
47
+ puts "Launchd tasks not done yet. Try again with a later build."
48
+ end
49
+
50
+ # desc "Start TorqueBox when running as a launchd daemon"
51
+ task :start=>[ :check ] do
52
+ puts "Launchd tasks not done yet. Try again with a later build."
53
+ end
54
+
55
+ # desc "Stop TorqueBox when running as an launchd daemon"
56
+ task :stop=>[ :check ] do
57
+ puts "Launchd tasks not done yet. Try again with a later build."
58
+ end
59
+
60
+ # desc "Restart TorqueBox when running as an launchd daemon"
61
+ task :restart=>[ :check ] do
62
+ puts "Launchd tasks not done yet. Try again with a later build."
63
+ end
64
+
65
+ end
66
+
67
+ namespace :upstart do
68
+ desc "Check if TorqueBox is installed as an upstart service"
69
+ task :check=>[ 'torquebox:check' ] do
70
+ TorqueBox::Upstart.check_install
71
+ puts "TorqueBox is installed as an upstart service at #{TorqueBox::Upstart.opt_torquebox}"
72
+ end
73
+
74
+ desc "Install TorqueBox as an upstart service"
75
+ task :install=>[ 'torquebox:check' ] do
76
+ TorqueBox::DeployUtils.create_symlink
77
+ TorqueBox::Upstart.copy_init_script
78
+ puts "Done! Ensure that you have a 'torquebox' user with ownership or write permissions of /opt/torquebox"
79
+ end
80
+
81
+ desc "Start TorqueBox when running as an upstart service"
82
+ task :start=>[ :check ] do
83
+ TorqueBox::DeployUtils.exec_command( 'start torquebox' )
84
+ end
85
+
86
+ desc "Stop TorqueBox when running as an upstart service"
87
+ task :stop=>[ :check ] do
88
+ TorqueBox::DeployUtils.exec_command( 'stop torquebox' )
89
+ end
90
+
91
+ desc "Restart TorqueBox when running as an upstart service"
92
+ task :restart=>[ :check ] do
93
+ TorqueBox::DeployUtils.exec_command( 'restart torquebox' )
94
+ end
95
+
96
+ end
34
97
  end
98
+
99
+
100
+
@@ -0,0 +1,56 @@
1
+ # Copyright 2011 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+
19
+ # Helpers for upstart rake tasks
20
+
21
+ require 'torquebox/deploy_utils'
22
+
23
+ module TorqueBox
24
+ module Upstart
25
+ class << self
26
+
27
+ def init_dir
28
+ File.join( TorqueBox::DeployUtils.sys_root, 'etc', 'init' )
29
+ end
30
+
31
+ def init_script
32
+ File.join( TorqueBox::DeployUtils.torquebox_home, 'share', 'init', 'torquebox.conf' )
33
+ end
34
+
35
+ def init_torquebox
36
+ File.join( init_dir, 'torquebox.conf' )
37
+ end
38
+
39
+ def copy_init_script
40
+ if File.writable?( init_dir )
41
+ FileUtils.cp( init_script, init_dir )
42
+ else
43
+ puts "Cannot write upstart configuration to #{init_dir}. You'll need to copy #{init_script} to #{init_dir} yourself."
44
+ end
45
+ end
46
+
47
+ def check_install
48
+ TorqueBox::DeployUtils.check_opt_torquebox
49
+ raise "#{init_torquebox} not installed in #{init_dir}" unless ( File.exist?( init_torquebox ) )
50
+ puts "TorqueBox init scripts OK: #{init_torquebox}"
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: torquebox-rake-support
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors: []
8
8
 
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-29 00:00:00 -04:00
13
+ date: 2011-05-25 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -27,6 +27,8 @@ files:
27
27
  - lib/org.torquebox.rake-support.rb
28
28
  - lib/torquebox-rake-support.rb
29
29
  - lib/torquebox/deploy_utils.rb
30
+ - lib/torquebox/launchd.rb
31
+ - lib/torquebox/upstart.rb
30
32
  - lib/torquebox/rake/tasks.rb
31
33
  - lib/torquebox/rake/tasks/archive.rb
32
34
  - lib/torquebox/rake/tasks/auth.rb