# deploy-restart

> Deploy an application to a remote Linux machine and restart a service using systemctl or other commands

Latest version **1.2.2** (published 2020-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install deploy-restart
pnpm add deploy-restart
yarn add deploy-restart
bun add deploy-restart
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2020-07-10 |
| First published | 2019-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rodrigo Cavanha |
| Maintainers | rdcavanha |
| Keywords | deploy, restart, ssh, systemctl, service, linux |

## Links

- npm: https://www.npmjs.com/package/deploy-restart
- Repository: https://github.com/rdcavanha/deploy-restart
- Homepage: https://github.com/rdcavanha/deploy-restart#readme
- Issues: https://github.com/rdcavanha/deploy-restart/issues
- npm.io page: https://npm.io/package/deploy-restart

## Dependencies (2)

- [scp2](https://npm.io/package/scp2.md) ^0.5.0
- [ssh-exec](https://npm.io/package/ssh-exec.md) ^2.0.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.2.2 (latest) — 2020-07-10
- 1.2.1 — 2020-07-10
- 1.2.0 — 2020-07-10
- 1.1.6 — 2020-06-20
- 1.1.5 — 2020-04-03
- 1.1.4 — 2019-09-19
- 1.1.3 — 2019-09-15
- 1.1.2 — 2019-09-13
- 1.1.1 — 2019-09-12
- 1.1.0 — 2019-09-12
- 1.0.1 — 2019-09-11
- 1.0.0 — 2019-09-11

## README

## deploy-restart
Deploy an application to a remote Linux machine and restart a service using systemctl or other commands

Install it through:

    npm i -D deploy-restart
<br />

**This module executes three basic steps:**
 1. Stops a service
 2. Copies files over SCP
 3. Starts a service
<br />

Written in TypeScript. It uses two core node modules:
 - ssh-exec: [https://github.com/mafintosh/ssh-exec](https://github.com/mafintosh/ssh-exec)
 - scp2: [https://github.com/spmjs/node-scp2](https://github.com/spmjs/node-scp2)
<br />

## Usage
```javascript
import { DeployRestart } from 'deploy-restart';

...

const deployRestart = new DeployRestart({
    user: 'john',
    host: '192.168.1.1',
    localPath: '/home/john/app/dist',
    remoteDeployPath: '/home/remote/services/app',
    restart: true,
    serviceName: 'app'
});

try {
    await deployRestart.start();
} catch (e) {
    console.error(e);
}
```

The start method resolves with ``void`` and rejects with the following object: 

```javascript
{
    stopServiceStatus: boolean;
    deployStatus: boolean;
    startServiceStatus: boolean;
    error: any; //Error thrown by the step that fails
}
````

## Options
|Name|Type|Required|
|--|--|--|
|user|string|Yes
|host|string|Yes
|localPath|string|Yes
|remoteDeployPath|string|Yes
|privateKeyPath|string|No
|password|string|No
|restart|boolean|No
<br />

If `restart` is true, then the following applies:

|Name|Default|Type|Required|
|--|--|--|--|
|serviceName||string|Yes if `serviceStartCommand` and `serviceStopCommand` are not provided
|serviceStartCommand|`sudo systemctl start serviceName`|string|Yes if `serviceName` is not provided or if `serviceStopCommand` is provided
|serviceStopCommand|`sudo systemctl stop serviceName`|string|Yes if `serviceName` is not provided or if `serviceStartCommand` is provided

In other words, you may either pass `serviceName` that will be executed as `sudo systemctl start serviceName` or pass both `serviceStartCommand` and `serviceStopCommand` to use your own commands.
<br />

## License
MIT

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