<commit_before>module Autoparts
  module Packages
    class Apache2 < Package
      name 'apache2'
      version '2.4.7'
      description 'Apache Web Server: A cross-platform open-source HTTP server for modern operating systems'
      source_url 'http://mirror.metrocast.net/apache/httpd/httpd-2.4.7.tar.gz'
      source_sha1 '9a73783b0f75226fb2afdcadd30ccba77ba05149'
      source_filetype 'tar.gz'

      depends_on 'apr'
      depends_on 'apr_util'

      def compile
        Dir.chdir('httpd-2.4.7') do
          File.open('config.layout', 'a') do |f|
            f.write config_layout_file
          end

          args = [
            "--with-apr=#{get_dependency("apr").prefix_path}",
            "--with-apr-util=#{get_dependency("apr_util").prefix_path}",
            "--enable-layout=Autoparts",
            # features
            "--disable-debug",
            "--disable-dependency-tracking",
            "--enable-so",
            "--enable-ssl",
            "--with-port=3000"
          ]
          execute './configure', *args
          execute 'make'
        end
      end

      def install
        Dir.chdir('httpd-2.4.7') do
          execute 'make install'
        end
      end

      def post_install
        execute 'mkdir', '-p', Path.var + 'apache2' + 'run'
        execute 'mkdir', '-p', Path.var + 'apache2' + 'log'

        # Setup configs.
        if apache_conf_path.exist?
          FileUtils.cp apache_conf_path, apache_conf_path.to_s + "." + Time.now.to_s
        else
          FileUtils.mkdir_p(File.dirname(apache_conf_path))
        end
        rewrite_config
        unless user_config_path.exist?
          user_config_path.mkpath
        end

        # Setup mime.types.
        FileUtils.cp '/etc/mime.types', mime_types_path

        # Setup document root.
        execute 'mkdir', '-p', htdocs_path
        if home_workspace_path.directory?
          home_workspace_htdocs_path.make_symlink(htdocs_path) unless home_workspace_htdocs_path.exist?
        end
      end

      def post_uninstall
        home_workspace_htdocs_path.unlink if home_workspace_htdocs_path.symlink?
      end

      def start
        execute bin_path + "apachectl", "start"
      end

      def stop
        execute bin_path + "apachectl", "stop"
      end

      def running?
        pid = Path.var + name + "run" + "httpd.pid"
        pid.exist?
      end
<commit_msg>apache status check<commit_after>module Autoparts
  module Packages
    class Apache2 < Package
      name 'apache2'
      version '2.4.7'
      description 'Apache Web Server: A cross-platform open-source HTTP server for modern operating systems'
      source_url 'http://mirror.metrocast.net/apache/httpd/httpd-2.4.7.tar.gz'
      source_sha1 '9a73783b0f75226fb2afdcadd30ccba77ba05149'
      source_filetype 'tar.gz'

      depends_on 'apr'
      depends_on 'apr_util'

      def compile
        Dir.chdir('httpd-2.4.7') do
          File.open('config.layout', 'a') do |f|
            f.write config_layout_file
          end

          args = [
            "--with-apr=#{get_dependency("apr").prefix_path}",
            "--with-apr-util=#{get_dependency("apr_util").prefix_path}",
            "--enable-layout=Autoparts",
            # features
            "--disable-debug",
            "--disable-dependency-tracking",
            "--enable-so",
            "--enable-ssl",
            "--with-port=3000"
          ]
          execute './configure', *args
          execute 'make'
        end
      end

      def install
        Dir.chdir('httpd-2.4.7') do
          execute 'make install'
        end
      end

      def post_install
        execute 'mkdir', '-p', Path.var + 'apache2' + 'run'
        execute 'mkdir', '-p', Path.var + 'apache2' + 'log'

        # Setup configs.
        if apache_conf_path.exist?
          FileUtils.cp apache_conf_path, apache_conf_path.to_s + "." + Time.now.to_s
        else
          FileUtils.mkdir_p(File.dirname(apache_conf_path))
        end
        rewrite_config
        unless user_config_path.exist?
          user_config_path.mkpath
        end

        # Setup mime.types.
        FileUtils.cp '/etc/mime.types', mime_types_path

        # Setup document root.
        execute 'mkdir', '-p', htdocs_path
        if home_workspace_path.directory?
          home_workspace_htdocs_path.make_symlink(htdocs_path) unless home_workspace_htdocs_path.exist?
        end
      end

      def post_uninstall
        home_workspace_htdocs_path.unlink if home_workspace_htdocs_path.symlink?
      end

      def start
        execute bin_path + "apachectl", "start"
      end

      def stop
        execute bin_path + "apachectl", "stop"
      end

      def running?
        pidFile = Path.var + name + "run" + "httpd.pid"
        if pidFile.exist?
          pid = File.read(mongod_pid_file_path).strip
          if pid.length > 0 && `ps -o cmd= #{pid}`.include?('httpd')
            return true
          end
        end
        false
      end

{'fraction_non_alphanumeric': 0.10678442392613409, 'fraction_numerical': 0.01746286631874749, 'mean_word_length': 1.8539518900343643, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '7370482', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1543, 'n_words': 315}