Bluepill.application("<%= app %>", :foreground => false, :log_file => "/var/log/bluepill.log") do |app|

  app.uid = "<%= user %>"
  app.gid = "<%= user %>"

<% engine.each_process do |name, process| %>
<% 1.upto(engine.formation[name]) do |num| %>
  <% port = engine.port_for(process, num) %>
  app.process("<%= name %>-<%= num %>") do |process|
    process.start_command = "<%= process.command %>"

    process.working_dir = "<%= engine.root %>"
    process.daemonize = true
    process.environment = <%= engine.env.merge("PORT" => port.to_s).inspect %>
    process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
    process.stop_grace_time = 45.seconds

    process.stdout = process.stderr = "<%= log %>/<%= app %>-<%= name %>-<%= num %>.log"

    process.monitor_children do |children|
      children.stop_command "kill {{PID}}"
    end

    process.group = "<%= app %>-<%= name %>"
  end
<% end %>
<% end %>
end

Bluepill.application("<%= app %>", :foreground => false, :log_file => "/var/log/bluepill.log") do |app|

  app.uid = "<%= user %>"
  app.gid = "<%= user %>"

<% engine.each_process do |name, process| %>
<% 1.upto(engine.formation[name]) do |num| %>
  <% port = engine.port_for(process, num) %>
  app.process("<%= name %>-<%= num %>") do |process|
    process.start_command = %Q{<%= process.command %>}

    process.working_dir = "<%= engine.root %>"
    process.daemonize = true
    process.environment = <%= engine.env.merge("PORT" => port.to_s).inspect %>
    process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
    process.stop_grace_time = 45.seconds

    process.stdout = process.stderr = "<%= log %>/<%= app %>-<%= name %>-<%= num %>.log"

    process.monitor_children do |children|
      children.stop_command "kill {{PID}}"
    end

    process.group = "<%= app %>-<%= name %>"
  end
<% end %>
<% end %>
end

Use %Q{} to allow commands with quotes
Use %Q{} to allow commands with quotes

I have this command in my Procfile: `sidekiq: bundle exec sidekiq -r "$(pwd)/app.rb"`. This generates an invalid ruby file. This commit uses %Q{} which allows for any combination of double quotes and single quotes.