Giter Site home page Giter Site logo

wrap's Introduction

Run command smart in tmux - WRAP

Build Status

WRAP runs command in detached tmux session, while capturing output to logfile.

Timestamps in logs are written in UTC timezone.

This execution is considered network/human fail safe, to some degree of course.

Motivation

During my last vacation at "The middle of nowhere" village, I was struggling to run commands on remote host and keep logs over smartphone tethering.

Usage

$ wrap <command> [<session>] [<logfile>]

If log filename is not provided, it would be created automatically. To guarantee filename on repeated calls, it's generated by SHA1 of command, eg. wrap.3b8ec645afd0203f086445d6a7aeccd98e5659ca.log.

Repeated execution of same WRAP command, would attach existing tmux session, if one is still running.

Note! Creating new window or pane within a session may affect standard workflow.

Install

$ git clone [email protected]:foodpanda/wrap.git && cd wrap
$ make install

Custom location

$ PREFIX=~/bin make install

Demo time

First run, Ctrl-c in the middle of execution.

$ T=v1.2.3 E=prod; wrap "./deployment.sh --env $E --tag $T --debug" deploy ~/"logs/deploy-${E}-${T}.log"
--> ./deployment.sh --env prod --tag v1.2.3 --debug <--
Ready to wrap this command? [y/N] y
> 2016-10-27 20:19:10 Tailing logs from '/home/jaymecd/logs/deploy-prod-v1.2.3.log' file ...
> 2016-10-27 20:19:10 Running: ./deployment.sh --env prod --tag v1.2.3 --debug
+ ./deployment.sh --env prod --tag v1.2.3 --debug
...
... (content clipped)
...
^C
Log still could be accessible via:
    $ tail -f /home/jaymecd/logs/deploy-prod-v1.2.3.log
    $ less /home/jaymecd/logs/deploy-prod-v1.2.3.log

Repeated run (while command is still running), press C-b d to detach tmux session.

$ T=v1.2.3 E=prod; wrap "./deployment.sh --env $E --tag $T --debug" deploy ~/"logs/deploy-${E}-${T}.log"
> press "C-b d" to detach <
[detached (from session deploy)]
+ ./deployment.sh --env prod --tag v1.2.3 --debug
...
... (content clipped)
...

real 2m32.002s
user 0m0.035s
sys  0m0.001s

> 2016-10-27 20:21:42 Finished (exit 0)
^C
Log still could be accessible via:
    $ tail -f /home/jaymecd/logs/deploy-prod-v1.2.3.log
    $ less /home/jaymecd/logs/deploy-prod-v1.2.3.log

wrap's People

Contributors

jaymecd avatar

Stargazers

林博仁 Buo-ren Lin avatar Sergey Novikov avatar

Watchers

 avatar James Cloos avatar

Forkers

jaymecd vicha111

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.