Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Make config file support both Rack and Rails #57

Open
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+14 −1
Split
@@ -198,6 +198,8 @@ def to_hash
{
'app_type' => application_type,
+ 'is_rails' => is_rails?,
+ 'is_rack' => is_rack?,
'config_path' => config_path,
'host' => @host.to_s,
'aliases' => @aliases.to_s,
@@ -221,6 +223,16 @@ def check_application_type
(File.exist?(env_file) and File.read(env_file) =~ RAILS_APP_REGEXP) ? RAILS : RACK
end
+ def is_rack?
+ config_ru_file = File.join(@path, 'config.ru')
+ File.exist?(env_file)
+ end
+
+ def is_rails?
+ env_file = File.join(@path, 'config', 'environment.rb')
+ File.exist?(env_file) && File.read(env_file) =~ RAILS_APP_REGEXP
+ end
+
def load_data_from_vhost_file(file = config_path)
data = File.read(file).strip
@@ -64,7 +64,8 @@ def create_vhost_conf(index)
" ServerName #{app['host']}",
(" ServerAlias #{app['aliases']}" unless app['aliases'].empty?),
" DocumentRoot \"#{public_dir}\"",
- " #{app['app_type'].capitalize}Env #{app['environment']}",
+ (" RailsEnv #{app['environment']}" if app['is_rails']),
+ (" RackEnv #{app['environment']}" if app['is_rack']),
(app['user_defined_data'] unless app['user_defined_data'].empty?),
"</VirtualHost>"
].compact.join("\n")