Class: Calatrava::Apache
- Inherits:
-
Object
- Object
- Calatrava::Apache
- Includes:
- Rake::DSL
- Defined in:
- lib/calatrava/apache.rb
Instance Method Summary collapse
- #apache_conf_dir ⇒ Object
- #apache_dir ⇒ Object
- #apache_logs_dir ⇒ Object
- #apache_public_dir ⇒ Object
- #configure_apache ⇒ Object
- #ensure_httpd ⇒ Object
- #httpd(command, opts = {}) ⇒ Object
- #install_tasks ⇒ Object
- #launch_apache(opts = {}) ⇒ Object
- #reload_apache ⇒ Object
- #stop_apache ⇒ Object
Instance Method Details
#apache_conf_dir ⇒ Object
33 34 35 |
# File 'lib/calatrava/apache.rb', line 33 def apache_conf_dir "#{apache_dir}/conf" end |
#apache_dir ⇒ Object
21 22 23 |
# File 'lib/calatrava/apache.rb', line 21 def apache_dir "web/apache" end |
#apache_logs_dir ⇒ Object
29 30 31 |
# File 'lib/calatrava/apache.rb', line 29 def apache_logs_dir "#{apache_dir}/logs" end |
#apache_public_dir ⇒ Object
25 26 27 |
# File 'lib/calatrava/apache.rb', line 25 def apache_public_dir "#{apache_dir}/public" end |
#configure_apache ⇒ Object
50 51 52 |
# File 'lib/calatrava/apache.rb', line 50 def configure_apache cp Calatrava::Project.current.config.path("httpd.conf"), apache_conf_dir end |
#ensure_httpd ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/calatrava/apache.rb', line 74 def ensure_httpd if !@httpd if `uname -a`.chomp["amzn1"] @httpd = "httpd" elsif `uname`.chomp == "Linux" @httpd = "apache2" elsif `uname`.chomp == "Darwin" @httpd = "httpd" else raise "Calatrava does not support running apache on this platform." end end end |
#httpd(command, opts = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/calatrava/apache.rb', line 37 def httpd(command, opts = {}) ensure_httpd cmd = %Q{#{@httpd} -d #{apache_dir} -f conf/httpd.conf -e DEBUG -k #{command} -DNO_DETACH -DFOREGROUND} puts cmd if opts[:background] fork do exec cmd end else exec cmd end end |
#install_tasks ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/calatrava/apache.rb', line 88 def install_tasks directory apache_logs_dir file apache_public_dir do cd apache_dir do ln_s "../public", "public" end end desc "launch a non-daemon apache instance on port 8888 which will serve our local app and also proxy to backend services" task :start => ['web:build', apache_public_dir, apache_logs_dir] do configure_apache launch_apache end task :background => ['web:build', apache_public_dir, apache_logs_dir] do configure_apache launch_apache :background => true end desc "Reload the apache configuration" task :reload do reload_apache end desc "Stop the apache configuration" task :stop do stop_apache end desc "Cleans apache config" task :clean do rm_rf apache_logs_dir rm_rf File.join(apache_conf_dir, 'httpd.conf') end end |
#launch_apache(opts = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/calatrava/apache.rb', line 54 def launch_apache(opts = {}) if !opts[:background] puts puts "\t\t" + "*"*40 puts "\t\t" + "*** STARTING APACHE ON PORT 8888 ***" puts "\t\t" + "*"*40 puts end httpd :start, opts end |
#reload_apache ⇒ Object
70 71 72 |
# File 'lib/calatrava/apache.rb', line 70 def reload_apache httpd :restart end |
#stop_apache ⇒ Object
66 67 68 |
# File 'lib/calatrava/apache.rb', line 66 def stop_apache httpd 'graceful-stop' end |