Skip to content

Commit ba315c6

Browse files
committed
If assets haven't been precompiled, fail to start server in production mode with a message
1 parent c372e36 commit ba315c6

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
# Check that the app is configured correctly. Raise some helpful errors if something is wrong.
22

3-
if Rails.env.production? && ['localhost', 'production.localhost'].include?(Discourse.current_hostname)
4-
puts <<END
3+
if defined?(Rails::Server) and Rails.env.production? # Only run these checks when starting up a production server
54

6-
Discourse.current_hostname = '#{Discourse.current_hostname}'
5+
if ['localhost', 'production.localhost'].include?(Discourse.current_hostname)
6+
puts <<END
77
8-
Please update the host_names property in config/database.yml
9-
so that it uses the hostname of your site. Otherwise you will
10-
experience problems, like links in emails using #{Discourse.current_hostname}.
8+
Discourse.current_hostname = '#{Discourse.current_hostname}'
9+
10+
Please update the host_names property in config/database.yml
11+
so that it uses the hostname of your site. Otherwise you will
12+
experience problems, like links in emails using #{Discourse.current_hostname}.
13+
14+
END
15+
16+
raise "Invalid host_names in database.yml"
17+
end
18+
19+
if !Dir.glob(File.join(Rails.root,'public','assets','application*.js')).present?
20+
puts <<END
21+
22+
Assets have not been precompiled. Please run the following command
23+
before starting the rails server in production mode:
24+
25+
rake assets:precompile
1126
1227
END
1328

14-
raise "Invalid host_names in database.yml"
29+
raise "Assets have not been precompiled"
30+
end
1531
end

0 commit comments

Comments
 (0)