Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gillesdemey/systemdify
:penguin: Automatically create a systemd unit file for your Node application
https://github.com/gillesdemey/systemdify
Last synced: 3 days ago
JSON representation
:penguin: Automatically create a systemd unit file for your Node application
- Host: GitHub
- URL: https://github.com/gillesdemey/systemdify
- Owner: gillesdemey
- License: mit
- Created: 2016-01-01T18:47:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-03T16:05:12.000Z (almost 9 years ago)
- Last Synced: 2024-04-13T16:34:05.156Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# systemdify
> Automatically create a systemd unit file for your Node application based on package.json
## Install
`npm install --save systemdify`
or to use the CLI
`npm install -g systemdify`
## Node API
```javascript
var systemdify = require('systemdify')var file = initdify({
command: 'node ./server.js',
description: 'My Awesome Application',
cwd: '/path/to/my-app/'
})```
Will return the following:
```
[Unit]
Description=My Awesome Application
After=network.target[Service]
Type=simple
ExecStart=node ./server.js
Restart=always
Environment=NODE_ENV=production
WorkingDirectory=/path/to/my-app[Install]
WantedBy=multi-user.target
```## CLI
Systemdify will figure out what to do automatically, so you don't have to.
Simply execute systemdify and it will generate a unit file for you based on your package.json file. It will place your unit file under `/etc/systemd/system/.service` by default.
Systemdify will try to use your `npm start` script and fall back to executing your `main` entry if you don't have one.
Systemdify will always exit cleanly when it issues a warning, but will fail if node is not installed on the system.
```
Usage
$ systemdifyOptions
-o, --output Write output to fileExamples
$ systemdify /path/to/my/app -o my-app.service
$ cat my-app.service[Unit]
description=My Application
...
```## NPM Hooks
The recommended way to use to module is to add it to your dev dependencies and execute the package after you've done an NPM install.
```json
...
scripts: {
"install": "sudo ./node_modules/.bin/systemdify"
},
devDepencencies: {
"systemdify": "^0.2.0"
}
...
```