Class: Nginx::Builder::Rails

Inherits:
Site
  • Object
show all
Defined in:
lib/shared_infrastructure/nginx/builder.rb

Direct Known Subclasses

RailsHttp, RailsHttps

Instance Attribute Summary collapse

Attributes inherited from Base

#domain, #server_blocks

Instance Method Summary collapse

Methods inherited from Site

#user

Methods inherited from Base

#https_reminder_message, #to_s

Constructor Details

#initialize(user, *server_blocks, domain: nil, rails_env: "production") ⇒ Rails

Returns a new instance of Rails.



166
167
168
169
# File 'lib/shared_infrastructure/nginx/builder.rb', line 166

def initialize(user, *server_blocks, domain: nil, rails_env: "production")
  @rails_env = rails_env
  super user, *server_blocks, domain: domain
end

Instance Attribute Details

#rails_envObject (readonly)

Returns the value of attribute rails_env.



170
171
172
# File 'lib/shared_infrastructure/nginx/builder.rb', line 170

def rails_env
  @rails_env
end

Instance Method Details

#saveObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/shared_infrastructure/nginx/builder.rb', line 172

def save
  SharedInfrastructure::Output.open(File.join("/etc/logrotate.d", "#{domain.domain_name}.conf"), "w") do |io|
    io << <<~LOGROTATE
      compress

      #{domain.rails_env_log(rails_env)} {
        size 1M
        rotate 4
        copytruncate
        missingok
        notifempty
      }
    LOGROTATE
  end &&
    Systemd::Rails.write_unit_file(domain.domain_name, domain, rails_env, user) &&
    super
end