Giter Club home page Giter Club logo

travis-tools's Introduction

travis-tools

Just some tools I've written for running jobs on CI systems like Travis, Shippable, etc.

runlog

This is a program similar to the travis_wait function - it runs a long-running command with output logged to a file. It occasionally prints a character to prevent timeout errors. If you hit the maximum runtime in minutes, it send a TERM signal, followed by a KILL signal. It exits with the same exit code or signal that your command exited with.

By default, it prints a period character every 30 seconds, and times out after 30 minutes. The log file name is generated randomly and printed on the first line of stdout. Each part of this can be customized:

runlog [-s sleeptime] [-c sleepchar] [-t timeout] [-l /path/to/log] [-h] -- program
  • sleeptime is how often to print your character, in seconds
  • sleepchar is the character (or string, if you want) to be printed.
  • timeout is how long to wait before sending a TERM/KILL, in minutes
  • -- (optional) can signal that you're no longer reading options.

The only thing printed to standard output is the logfile name with a newline, so you can run something like:

LOGFILE=$(./runlog -s 1 -t 1 -- /bin/sh -e -c "echo some output && sleep 90")
ecode=$?

if [ $ecode != 0 ] ; then
    printf "Error, here's the logfile ($LOGFILE)\n"
    cat "${LOGFILE}"
    exit 1
fi

And your output will be:

............................................................
Reached timeout, sending SIGTERM
Process ended with signal 15 (Terminated)
Terminated
Error, here's the logfile (/tmp/runlog-qenYlg)
some output

Another example:

runlog -s 1 -c ๐Ÿ’ฉ -t 5 -- sleep 600

Will run the command "sleep 600" in the background. In the foreground, it will print the "๐Ÿ’ฉ" character to stderr every second for a maximum of 5 minutes. Once it reaches 5 minutes, it will send a TERM signal to sleep.

Licensing

MIT-licensed, see LICENSE for details.

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.