Git Product home page Git Product logo

service-wait's Introduction

service-wait

Wrapper around service control command making sure that the service is really running after start.

Motivation

Imagine a simple process of setting up your web application, that includes:

  1. installing a database server
  2. starting the server
  3. preseeding the data

And now imagine, that service $DATABASE_SERVER start finishes but the service is still unavailable due to setup procedures. This happens with almost every network service.

Also, some services do not start or stop properly and return non-zero values for some commands.

This simple wrapper works with any service and just pass over the request to service controller, but for few problematic ones it waits until service is fully started or stopped.

CLI

Service-wait let's you specify what it means the service is running using a plugin architecture (with simple bash scripts).

Then, instead of service $DATABSE_SERVER start you use service-wait $DATABASE_SERVER start.

Puppet

Now imagine that you want to automate the described setup process using Puppet. This library includes a Puppet provider for service resources that wraps the service-wait script so that you can reuse the existing puppet modules that make sure that the required services are really running.

Plugin anatomy

The plugins can be found in plugins directory (or specifying using $PLUGINS_DIR environment variable.

Here is an annotated example:

# REQUIRED: test so determine if this plugin is usable with given service
confine [ $SERVICE = 'tomcat6' -o $SERVICE = 'tomcat7' ]

# OPTIONAL: sometimes the service command fails even if the service
#           starts (some bug probably). This let's you to ignore the
#           exit code of the original service command and use your
#           criteria on determining whether the service is running or
#           not.
ignore-retval

# this function gets loaded when the serivce is started/restarted and
# it should finish when the service is really running (performing some
# periodic checks on the status).
service-wait () {
    # the status can be determined by asking on some url
    wait-for-url http://localhost:3000
    # or the service listening on a port
    wait-for-port 3000
    # or some command to be successful
    wait-for-command serviceready

    # the status can be checked using $RETVAL variable
    if [ $RETVAL -eq 0 ]; then
       echo "success"
    fi
}

Supported OSes

Currently, service-wait is tested with RHEL/CentOS/Fedora distributions.

License

Copyright 2013 Red Hat, Inc. GPLv2

service-wait's People

Contributors

inecas 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.