npm package: @runspace/daemon
Description: RunSpace Daemon
Author: Mikhail Marynenko
Latest version: 0.2.0

# @runspace/daemon

![Docker](https://github.com/runspacegit/daemon/workflows/Docker/badge.svg) ![GitHub package.json version](https://img.shields.io/github/package-json/v/runspacegit/daemon) [![Maintainability](https://api.codeclimate.com/v1/badges/be26fc4185fd9cf8b186/maintainability)](https://codeclimate.com/github/runspacegit/daemon/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/test_coverage)](https://codeclimate.com/github/codeclimate/codeclimate/test_coverage)

Runspace daemon allows you to create P2P network of nodes for executing [@runspace/runtime](https://github.com/runspacegit/runtime) functions.

## Executing functions

See [@runspace/cli](https://github.com/runspacegit/cli#runspace-daemonbroadcast-file) [daemon:broadcast](https://github.com/runspacegit/cli#runspace-daemonbroadcast-file) for example.

## Functions Examples

See it [here](https://github.com/runspacegit/cli/tree/master/examples/functions), or [here](https://github.com/runspacegit/runtime/tree/master/example).

## Functions Runtime

See it here: [@runspace/runtime](https://github.com/runspacegit/runtime#runspaceruntime)

[Features is here](https://github.com/runspacegit/runtime#features)

## Configuration

Configuration is located in user home directory under folder `.runspace` and file `config.json`

### Configuration file

`$HOME/.devspace/config.json`

```json
{
  "os": {
    "homedir": $HOME,
    "user": $USER
  },
  "network": {
    "name": "runspacenet", // Network name
    "bridgePort": 65535 // Bridge port
  }
}
```

## Installing

### Prerequisites

- [Node.js](https://nodejs.org) >= 10.x
- [Yarn](https://yarnpkg.org)
- [pm2](https://pm2.keymetrics.io/) [Optional]

### macOS

- Install brew

```cosnole
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

- Install Node.js and Yarn

```console
$ brew install nodejs yarn
```

- Install pm2

```console
$ yarn global add pm2
```

- Clone Repository

```console
$ git clone https://github.com/runspacegit/daemon.git runspace-daemon
$ cd runspace-daemon
```

- Install deps

```console
$ yarn install
```

- Build daemon

```console
$ yarn build
```

- Start daemon

```console
$ pm2 start .
```

- See logs

```console
$ pm2 logs
```

- Autostart

```console
$ pm2 autostart
$ pm2 save
```

### Ubuntu

- Install Node.js and Yarn

```console
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ sudo apt install -y nodejs
```

```console
$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt install -y yarn
```

- Install pm2

```console
$ sudo yarn global add pm2
```

- Clone Repository

```console
$ git clone https://github.com/runspacegit/daemon.git runspace-daemon
$ cd runspace-daemon
```

- Install deps

```console
$ yarn install
```

- Build daemon

```console
$ yarn build
```

- Start daemon

```console
$ pm2 start .
```

- See logs

```console
$ pm2 logs
```

- Autostart

```console
$ pm2 autostart
$ pm2 save
```

### Windows

❌⏳ Tutorial Under construction

But it will work under windows.