<commit_before>require 'mail_catcher'

module Extensions
  module SMTP
    class Server
      def run!(session, options)
        @process = Process.fork {
          $0 = "stubby: [extension worker sub] Extensions::SMTP::Server"

          sleep 2

          HTTPI.post("http://#{STUBBY_MASTER}:9000/stubs/transient/activate.json",
            options: MultiJson.dump(smtp_stub), key: "_smtp")
          
          while true
            begin
              MailCatcher.run! smtp_ip: STUBBY_MASTER,
                smtp_port: 25,
                http_ip: STUBBY_MASTER,
                http_port: 9001,
                daemon: false
            rescue
              puts $!
            end
          end
        }

        trap("INT", important: true){
          stop!
        }
      end

      def smtp_stub
        {
          "dns://outbox.stubby.dev/a" => "dns-a://#{STUBBY_MASTER}",
          "http://outbox.stubby.dev" => "http://#{STUBBY_MASTER}:9001"
        }
      end

      def expand_rule(trigger, instruction)
        {<commit_msg>Fixes the shutdown issue on smtp server<commit_after>require 'mail_catcher'

module Extensions
  module SMTP
    class Server
      def run!(session, options)
        @process = Process.fork {
          $0 = "stubby: [extension worker sub] Extensions::SMTP::Server"

          sleep 2

          HTTPI.post("http://#{STUBBY_MASTER}:9000/stubs/transient/activate.json",
            options: MultiJson.dump(smtp_stub), key: "_smtp")
          
          MailCatcher.run! smtp_ip: STUBBY_MASTER,
            smtp_port: 25,
            http_ip: STUBBY_MASTER,
            http_port: 9001,
            daemon: false
        }

        trap("INT", important: true){
          stop!
        }

        sleep
      end

      def smtp_stub
        {
          "dns://outbox.stubby.dev/a" => "dns-a://#{STUBBY_MASTER}",
          "http://outbox.stubby.dev" => "http://#{STUBBY_MASTER}:9001"
        }
      end

      def expand_rule(trigger, instruction)
        {
{'fraction_non_alphanumeric': 0.11494252873563218, 'fraction_numerical': 0.015992003998001, 'mean_word_length': 1.6238532110091743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5499256', 'n_tokens_mistral': 667, 'n_tokens_neox': 652, 'n_words': 118}