# v-daemon

> Daemon script for v-spot-client

Latest version **2.0.3** (published 2017-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install v-daemon
pnpm add v-daemon
yarn add v-daemon
bun add v-daemon
```

Provides the command `v-daemon`.

## 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 | 2.0.3 |
| Published | 2017-12-11 |
| First published | 2017-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | okunishinishi |
| Maintainers | realglobe, okunishinishi |
| Keywords | v |

## Links

- npm: https://www.npmjs.com/package/v-daemon
- Repository: https://github.com/realglobe-Inc/v-daemon
- Homepage: https://github.com/realglobe-Inc/v-daemon#readme
- Issues: https://github.com/realglobe-Inc/v-daemon/issues
- npm.io page: https://npm.io/package/v-daemon

## Dependencies (7)

- [argx](https://npm.io/package/argx.md) ^3.0.2
- [aglob](https://npm.io/package/aglob.md) ^3.0.0
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [commander](https://npm.io/package/commander.md) ^2.12.2
- [v-connector](https://npm.io/package/v-connector.md) ^1.0.1
- [v-constants](https://npm.io/package/v-constants.md) ^1.1.0
- [shiba-daemon-util](https://npm.io/package/shiba-daemon-util.md) ^3.0.0

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 2.0.3 (latest) — 2017-12-11
- 2.0.2 — 2017-12-11
- 2.0.1 — 2017-12-07
- 2.0.0 — 2017-12-07
- 1.2.5 — 2017-12-04
- 1.2.4 — 2017-11-28
- 1.2.3 — 2017-11-28
- 1.2.2 — 2017-11-28
- 1.2.1 — 2017-11-28
- 1.2.0 — 2017-11-27
- 1.1.6 — 2017-11-27
- 1.1.5 — 2017-11-25
- 1.1.4 — 2017-11-25
- 1.1.3 — 2017-11-24
- 1.1.2 — 2017-11-24
- … 5 more at https://npm.io/package/v-daemon/versions

## README

v-daemon
==========

<!---
This file is generated by ape-tmpl. Do not update manually.
--->

<!-- Badge Start -->
<a name="badges"></a>

[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url]

[bd_repo_url]: https://github.com/realglobe-Inc/v-daemon
[bd_travis_url]: http://travis-ci.org/realglobe-Inc/v-daemon
[bd_travis_shield_url]: http://img.shields.io/travis/realglobe-Inc/v-daemon.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/realglobe-Inc/v-daemon
[bd_travis_com_shield_url]: https://api.travis-ci.com/realglobe-Inc/v-daemon.svg?token=
[bd_license_url]: https://github.com/realglobe-Inc/v-daemon/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/realglobe-Inc/v-daemon
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/realglobe-Inc/v-daemon.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/realglobe-Inc/v-daemon.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/realglobe-Inc/v-daemon
[bd_gemnasium_shield_url]: https://gemnasium.com/realglobe-Inc/v-daemon.svg
[bd_npm_url]: http://www.npmjs.org/package/v-daemon
[bd_npm_shield_url]: http://img.shields.io/npm/v/v-daemon.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg

<!-- Badge End -->


<!-- Description Start -->
<a name="description"></a>

Daemon script for v-spot-client

<!-- Description End -->


<!-- Overview Start -->
<a name="overview"></a>



<!-- Overview End -->


<!-- Sections Start -->
<a name="sections"></a>

<!-- Section from "doc/guides/01.Installation.md.hbs" Start -->

<a name="section-doc-guides-01-installation-md"></a>

Installation
-----

```bash
$ npm install v-daemon -g
```


<!-- Section from "doc/guides/01.Installation.md.hbs" End -->

<!-- Section from "doc/guides/02.Usage.md.hbs" Start -->

<a name="section-doc-guides-02-usage-md"></a>

Usage
---------

Step01: Create script file to run. File basename will be the subject id

**/home/scripts/v/jp.realglobe.v-daemon.example01**

```javascript
#!/usr/bin/env node

/**
 * @file Example script to daemonize
 */
'use strict'

// verb and object passed as process args
const [, , subject, verb, object1, object2] = process.argv

switch (verb) {
  case 'sayHi': {
    process.stdout.write(`Hi, ${object1} and ${object2}`)
    break
  }
  default:
    throw new Error(`Unknown verb: ${verb}`)
}
```


Step02: Daemonize the script

```bash
#!/bin/bash

# Give script path to daemonize

v-daemon /home/scripts/v/jp.realglobe.v-daemon.example01 -H "v-spot.cloud.com"
```

Step03: Call it from another client
```javascript
#!/usr/bin/env node

/**
 * Example to call daemonized script
 */
'use strict'

const vSpot = require('v-spot')

;(async () => {
  const spot = vSpot().client()

  await spot.connect('v-spot.cloud.com')

  // By default, subject name is generated from script name
  const example01 = await spot.use('jp.realglobe.v-daemon.example01')
  // Send the signal to daemon script via server
  await example01.sayHi('can you hear me?', 'really?')
})()

```


### More Script Examples

**Bash Script Example**
```bash
#!/bin/bash
#

subject=$1
verb=$2
object1=$3
object2=$4

if [[ ${verb} == *"sayHi"* ]]
then
  printf "Hi, ${object1} and ${object2}"
  exit
fi

echo "Unknown verb ${verb}"
exit 1
```


### CLI Help

```bash

  Usage: v-daemon [options] <filename ...> 

  Daemon script for v-spot-client


  Options:

    -V, --version                output the version number
    -H, --hostname [hostname]    List available tasks
    -p, --port [port]            Port number
    -P, --protocol [protocol]    Protocol
    -c, --connector [connector]  connection type
    -i, --id [id]                Subject ID
    -q, --quiet [quiet]          No messages
    -v, --verbose [verbose]      Show verbose log
    -h, --help                   output usage information

```

<!-- Section from "doc/guides/02.Usage.md.hbs" End -->

<!-- Section from "doc/guides/10.API Guide.md.hbs" Start -->

<a name="section-doc-guides-10-a-p-i-guide-md"></a>

API Guide
-----

+ [v-daemon@2.0.3](./doc/api/api.md)


<!-- Section from "doc/guides/10.API Guide.md.hbs" End -->


<!-- Sections Start -->


<!-- LICENSE Start -->
<a name="license"></a>

License
-------
This software is released under the [MIT License](https://github.com/realglobe-Inc/v-daemon/blob/master/LICENSE).

<!-- LICENSE End -->


<!-- Links Start -->
<a name="links"></a>

Links
------

+ [v][v_url]
+ [Realglobe, Inc.][realglobe,_inc__url]

[v_url]: https://github.com/realglobe-Inc/v
[realglobe,_inc__url]: http://realglobe.jp

<!-- Links End -->

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