# chillin

> NPM package API and Bash/CLI tool to implement waiting on an external resource's availability.

Latest version **1.0.4** (published 2015-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install chillin
pnpm add chillin
yarn add chillin
bun add chillin
```

Provides the command `chillin`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2015-12-22 |
| First published | 2015-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+8 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Grimes |
| Maintainers | csgrimes1 |
| Keywords | wait, readiness, availability |

## Links

- npm: https://www.npmjs.com/package/chillin
- Repository: https://github.com/csgrimes1/chillin
- Homepage: https://github.com/csgrimes1/chillin#readme
- Issues: https://github.com/csgrimes1/chillin/issues
- npm.io page: https://npm.io/package/chillin

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) 3.10.1
- [minimist](https://npm.io/package/minimist.md) 1.2.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2015-12-22
- 1.0.3 — 2015-12-22
- 1.0.2 — 2015-12-22
- 1.0.1 — 2015-12-21
- 1.0.0 — 2015-12-21

## README

## Introduction

This tool is intended to be used either in bash or a node.js project. It waits for a resource
(such as a database) to become available, then it starts another process. It just chills until
the timeout expires or the wait condition is satisfied.

Let's illustrate with
an example. Say you have a Docker Compose environment that starts containers _S_ and _D_ (for _database_).
_S_ depends on _D_, but _D_ can be slow to start up. _S_ can use _chillin_ in either of two ways.

1. The NodeJS startup script can be modified to use the _chillin_ NPM package.
2. A startup bash script can utilize the _chillin_ CLI.

_Please Note_ Chillin uses EcmaScript 6. It will not run on older versions of NodeJS!

## NodeJS Example

```javascript
const chillin = require('chillin')
    , promise = chillin.loadWaiterModule('port')
        .configure('host', 'www.google.com')
        .configure('port', 80)
        .start()

promise.then(function(){
    console.log('OK!')
}, function(x){
    console.error(`Failed: ${x}`)
})

```

## To Run Chillin Inside Your Project
```
> npm install chillin --save-dev
> export PATH=$PATH:$(npm bin)
> chillin port www.google.com 80
```

## BASH Example

Please reference the example above if you are installing Chillin in your project rather than as a global
package. The line that changes the PATH variable can be added to the example below to make it run with
a locally installed package.

```bash
#!/usr/bin/env bash

if [ $# -lt 1 ]; then
    echo "Name/IP of Postgres server required." 1>&2;
    echo "> $0 PGSERVER" 1>&2;
    exit 1
fi

#If you want to suppress error output on failure, you can redirect
#stderr to null on the next line.
chillin port $1 5432
#Get the exit code
RESULT=$?

if [ $RESULT == 0 ]; then
    echo "Starting the program that depends on Postgres..."
else
    echo "Failed! Not starting the program." 1>&2
    exit $RESULT
fi


```

## Types of Waits
There are three built-in waiter modules: _port_, _exec_, and _mock_. The _port_ waiter is shown in the examples. The
_exec_ module waits for a process to start and complete or time out. The _mock_ module is for testing purposes. Other
modules may be loaded using a path consistent with _require()_ in NodeJS.

## The _port_ Waiter
`chillin www.github.com 80 --timeout 2000`

The positional arguments are `ADDRESS PORT`

## The _exec_ Waiter
`chillin --timeout 2000 echo "Hello"`

The positional arguments correspond to `COMMAND arg1 arg2 ... argN`

---
_Source: https://npm.io/package/chillin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
