<commit_before><%#
This custom template handles a few unusual requirements, including the use of
RVM for "bundle exec" commands.

Use with caution, as it really is an attempt to avoid writting a custom bluepill
script, rather than a solid "works anywhere" template.
%>
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|
    <%
      cmd = process.command
      if cmd =~ /^bundle exec/
        if `which ruby ` =~ /\/\.rvm\//
          current_ruby = `rvm current`.chomp
          `rvm wrapper #{current_ruby} #{app} bundle`
          cmd.sub!(/^bundle/, `which #{app}_bundle`.chomp)
        else
          cmd.sub!(/^bundle/, `which bundle`.chomp)
        end
      end
      cmd.sub!(/\$PORT/, port.to_s)
    %>
    process.start_command = "<%= cmd %>"

    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<commit_msg>Adding absolute path substitution to template.<commit_after><%#
This custom template handles a few unusual requirements, including the use of
RVM for "bundle exec" commands.

Use with caution, as it really is an attempt to avoid writting a custom bluepill
script, rather than a solid "works anywhere" template.
%>
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|
    <%
      cmd = process.command
      if cmd =~ /^bundle exec/
        if `which ruby ` =~ /\/\.rvm\//
          current_ruby = `rvm current`.chomp
          `rvm wrapper #{current_ruby} #{app} bundle`
          cmd.sub!(/^bundle/, `which #{app}_bundle`.chomp)
        else
          cmd.sub!(/^bundle/, `which bundle`.chomp)
        end
      else
        cmd.sub!(/^(\S+)/) { `which #{$1}`.chomp }
      end
      cmd.sub!(/\$PORT/, port.to_s)
    %>
    process.start_command = "<%= cmd %>"

    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
{'fraction_non_alphanumeric': 0.18633729795669413, 'fraction_numerical': 0.003964623360780726, 'mean_word_length': 2.8497652582159625, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '776497', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1074, 'n_words': 278}