https://github.com/caseywebdev/bootman
Start (and stop) services dependent on one another in order
https://github.com/caseywebdev/bootman
Last synced: 5 months ago
JSON representation
Start (and stop) services dependent on one another in order
- Host: GitHub
- URL: https://github.com/caseywebdev/bootman
- Owner: caseywebdev
- Created: 2020-04-01T20:02:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-28T22:02:04.000Z (over 1 year ago)
- Last Synced: 2025-09-22T19:58:51.946Z (10 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bootman
### Start and stop services dependent on one another in order
## Usage
#### 1. Define Individual Services
```js
// services/d.js
export default {
dependsOn: ['a', 'b', 'c'], // Services which must be started prior to this service
start: () => {}, // Start up function, called when this service is started
stop: () => {} // Teardown function, called when this service is stopped
};
```
#### 2. Initialize Bootman with Defined Services
```js
// services/index.js
import { createServiceController } from 'bootman';
import a from 'services/a.js';
import b from 'services/b.js';
import c from 'services/c.js';
import d from 'services/d.js';
export default createServiceController({ a, b, c, d });
```
#### 3. Start or Stop Services
##### Start
```js
import services from 'services/index.js';
export default services.start(['d']);
/*
In this particular example, since service d dependsOn services a, b, and c,
all three of those services must be in a "started" state before service d
will be started.
The .start and .stop functions accepts either an individual name, i.e. 'd'
or an array of names, i.e. ['d', 'c', 'b', 'a'].
*/
```
##### Stop
```js
// Stop a service
import services from 'services/index.js';
export default services.stop(['d']);
```