GithubHelp home page GithubHelp logo

http_server_manager's Introduction

http_server_manager

Aims to simplify managing the lifecycle of HTTP server processes.

Given a server start-up command, http_server_manager can:

  • Start the server, which creates a pid file, redirects stdout and stderr to a log file and blocks until started
  • Provide the status of the server (started or stopped)
  • Stop the server, killing the servers process tree and deleting the generated pid file
  • Restart the server, stopping a potentially running server and then starting it

It is currently distributed as a development and testing tool and is not recommended for production use.

Motivation

For projects whose production environment is completed managed by a PaaS provider, such as Heroku or Engine Yard, using god or monit to manage your http processes in development and test environments can be overkill.

http_server_manager provides a simple means of managing the lifecycle of these processes in these environments.

It is particularly useful for automated management of these processes as part of a continuous integration pipeline.

Usage

Step 1: Install via gem install http_server_manager or gem 'http_server_manager in your Gemfile

Step 2: Require:

    require 'http_server_manager'

Step 3: Configure the location of server pid files and logs:

    HttpServerManager.pid_dir = "some/pid/dir"
    HttpServerManager.log_dir = "some/log/dir"

Step 4: Create a server class:

    require 'http_server_manager'

    class MyServer < HttpServerManager::Server

        def initialize
            super(name: :my_server, port: 3000)
        end

        def start_command
          "rackup -p #{@port} my/server_config.ru"
        end

    end

Step 5: Control the status of the server:

    server = MyServer.new

    server.start! # blocks until server is running

    server.status # returns :started

    server.restart! # kills process

    server.status # returns :started

    server.stop! # kills process

    server.status # returns :stopped

Alternatively, via Rake:

    require 'http_server_manager/rake/task_generators'

    HttpServerManager::Rake::ServerTasks.new(server)
    # Generates tasks:
    # my_server:start
    # my_server:restart
    # my_server:stop
    # my_server:status

Testing

Ensure that your server is configured correctly:

    require 'http_server_manager/test_support'

    describe MyServer do

      include_context "managed http server integration utilities" # Provided by http_server_manager as a test utility

      let(:server) { MyServer.new }

      describe "#start!" do

        after(:each) { force_stop! }

        it "should start the server via the provided command" do
          server.start!

          wait_until_started!
        end

      end

For those not using RSpec, see http_server_manager/test/server_integration_utilities.rb

OS Support

Mac and Windows

Requirements

  • Ruby 1.9

Build Status

Build Status

http_server_manager's People

Contributors

dueckes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.