Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
2bacccd
Fixed NullPointerException if `-i` option was not given
BenjaminGuzman Sep 5, 2021
9bd35d7
Fixed error child processes were not being destroyed on exit (with ex…
BenjaminGuzman Sep 7, 2021
f27bfbe
Improvements to CLI command processing
BenjaminGuzman Sep 7, 2021
5d7078e
Added stop command and started working on other commands
BenjaminGuzman Sep 13, 2021
5be122a
Added `print` command to write dot code
BenjaminGuzman Oct 10, 2021
fe67450
Create maven.yml
BenjaminGuzman Oct 10, 2021
4e8dc92
Fixed error with ConfigToDotTest
BenjaminGuzman Oct 10, 2021
7edd9df
Merge remote-tracking branch 'origin/main'
BenjaminGuzman Oct 10, 2021
f7521cf
Removed unnecessary System.out.println in ConfigToDotTest
BenjaminGuzman Oct 10, 2021
0f0d96f
Improved redaction in README.md
BenjaminGuzman Oct 10, 2021
0c91ed0
Added `start`, `stop`, `status` commands
BenjaminGuzman Oct 10, 2021
65203e5
Improved redaction in code
BenjaminGuzman Oct 10, 2021
40f7b9d
Fixed grandchildren processes were not being stopped correctly.
BenjaminGuzman Oct 12, 2021
8d0af9b
Added support for YAML config files
BenjaminGuzman Oct 12, 2021
ef3365b
Improvements to process management & status printing
BenjaminGuzman Oct 12, 2021
d5fdeb1
Migrated to picocli
BenjaminGuzman Oct 13, 2021
a45c530
Create dependabot.yml
BenjaminGuzman Oct 13, 2021
0304fff
Bump annotations from 21.0.1 to 22.0.0
dependabot[bot] Oct 13, 2021
c64ad34
Bump junit-jupiter from 5.8.0-M1 to 5.8.1
dependabot[bot] Oct 13, 2021
74f2850
Bump maven-assembly-plugin from 3.2.0 to 3.3.0
dependabot[bot] Oct 13, 2021
b1cebab
Bump org.everit.json.schema from 1.13.0 to 1.14.0
dependabot[bot] Oct 13, 2021
df7b641
Merge pull request #4 from BenjaminGuzman/dependabot/maven/com.github…
BenjaminGuzman Oct 13, 2021
d64cd45
Merge pull request #3 from BenjaminGuzman/dependabot/maven/org.apache…
BenjaminGuzman Oct 13, 2021
b097114
Merge pull request #2 from BenjaminGuzman/dependabot/maven/org.junit.…
BenjaminGuzman Oct 13, 2021
47809ee
Merge pull request #1 from BenjaminGuzman/dependabot/maven/org.jetbra…
BenjaminGuzman Oct 13, 2021
ae03d66
Removed unnecessary print
BenjaminGuzman Oct 17, 2021
75f0e69
Create maven-publish.yml
BenjaminGuzman Oct 17, 2021
2a18ab9
Delete maven-publish.yml
BenjaminGuzman Oct 17, 2021
769a8d1
Update Service.java
BenjaminGuzman Oct 23, 2021
19daf93
Bump picocli from 4.6.1 to 4.6.2
dependabot[bot] Nov 8, 2021
5e35b1d
Merge pull request #5 from BenjaminGuzman/dependabot/maven/info.picoc…
BenjaminGuzman Nov 8, 2021
a26d915
Bump annotations from 22.0.0 to 23.0.0
dependabot[bot] Nov 11, 2021
22233ca
Merge pull request #6 from BenjaminGuzman/dependabot/maven/org.jetbra…
BenjaminGuzman Nov 11, 2021
c0cdf08
Bump junit-jupiter from 5.8.1 to 5.8.2
dependabot[bot] Nov 29, 2021
fb0e833
Merge pull request #7 from BenjaminGuzman/dependabot/maven/org.junit.…
BenjaminGuzman Dec 14, 2021
e5ad4b7
Bump snakeyaml from 1.29 to 1.30
dependabot[bot] Dec 16, 2021
e2a291c
Merge pull request #9 from BenjaminGuzman/dependabot/maven/org.yaml-s…
BenjaminGuzman Dec 16, 2021
8b22808
Update README.md
BenjaminGuzman Dec 22, 2021
474619a
Bump picocli from 4.6.2 to 4.6.3
dependabot[bot] Feb 9, 2022
eab9f87
Bump maven-compiler-plugin from 3.8.1 to 3.10.0
dependabot[bot] Feb 14, 2022
d02d7ed
Merge pull request #12 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Feb 16, 2022
4860e15
Merge pull request #11 from BenjaminGuzman/dependabot/maven/info.pico…
BenjaminGuzman Feb 16, 2022
c2bb08f
Bump maven-compiler-plugin from 3.10.0 to 3.10.1
dependabot[bot] Mar 11, 2022
f67a820
Bump org.everit.json.schema from 1.14.0 to 1.14.1
dependabot[bot] Apr 1, 2022
629d55c
Bump maven-surefire-plugin from 3.0.0-M5 to 3.0.0-M7
dependabot[bot] Jun 7, 2022
4b124ab
Bump maven-assembly-plugin from 3.3.0 to 3.4.0
dependabot[bot] Jul 4, 2022
346f779
Merge pull request #18 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Jul 7, 2022
687a9ce
Merge pull request #17 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Jul 7, 2022
1ae0b1e
Merge pull request #13 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Jul 7, 2022
8217b32
Merge pull request #15 from BenjaminGuzman/dependabot/maven/com.githu…
BenjaminGuzman Jul 7, 2022
da3a258
Bump maven-assembly-plugin from 3.4.0 to 3.4.2
dependabot[bot] Jul 25, 2022
6f1d8eb
Bump junit-jupiter from 5.8.2 to 5.9.1
dependabot[bot] Sep 21, 2022
e2ebd52
Bump snakeyaml from 1.30 to 1.33
dependabot[bot] Sep 26, 2022
f688cd7
Merge pull request #26 from BenjaminGuzman/dependabot/maven/org.yaml-…
BenjaminGuzman Sep 28, 2022
5655a37
Merge pull request #24 from BenjaminGuzman/dependabot/maven/org.junit…
BenjaminGuzman Sep 28, 2022
f160e39
Merge pull request #20 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Sep 28, 2022
c77414e
Bump picocli from 4.6.3 to 4.7.0
dependabot[bot] Nov 1, 2022
5799d16
Added installer (install.sh and microstart.sh)
BenjaminGuzman Nov 21, 2022
ef4fb66
Changed default config file from microstart.yaml to microstart.yml
BenjaminGuzman Nov 21, 2022
e823fe6
Fixed bug in install.sh
BenjaminGuzman Nov 21, 2022
e401278
Released v0.9
BenjaminGuzman Nov 21, 2022
b46a47a
Added `load` subcommand
BenjaminGuzman Dec 1, 2022
7b28dfc
Merge pull request #27 from BenjaminGuzman/dependabot/maven/info.pico…
BenjaminGuzman Dec 1, 2022
18eb2c5
Improvements to `status` subcommand
BenjaminGuzman Dec 1, 2022
2f87074
Minor typo fix
BenjaminGuzman Dec 1, 2022
574f9e2
Improved exception log message
BenjaminGuzman Dec 5, 2022
427ccc1
Included PID when logging status
BenjaminGuzman Dec 8, 2022
ef89efa
Added command forwarding capability
BenjaminGuzman Dec 8, 2022
892bc04
Improved command forwarding by yielding control (inherited IO)
BenjaminGuzman Dec 8, 2022
f560552
Bump annotations from 23.0.0 to 23.1.0
dependabot[bot] Dec 9, 2022
fe23d42
Merge pull request #28 from BenjaminGuzman/dependabot/maven/org.jetbr…
BenjaminGuzman Dec 9, 2022
6751940
Updated org.json dependency to version 20220924
BenjaminGuzman Dec 29, 2022
f472f09
Merge remote-tracking branch 'origin/main'
BenjaminGuzman Dec 29, 2022
9bf166b
Added `reload` subcommand
BenjaminGuzman Jan 3, 2023
765b304
Released v1.0
BenjaminGuzman Jan 3, 2023
2eeb431
Released v1.0.1
BenjaminGuzman Jan 4, 2023
7c4aca6
Bump junit-jupiter from 5.9.1 to 5.9.2
dependabot[bot] Jan 11, 2023
1561ee3
Bump annotations from 23.1.0 to 24.0.0
dependabot[bot] Jan 12, 2023
391d408
Bump maven-surefire-plugin from 3.0.0-M7 to 3.0.0-M8
dependabot[bot] Jan 12, 2023
ab53c9c
Released v1.1
BenjaminGuzman Jan 29, 2023
9ec2a23
Added `group status` command
BenjaminGuzman Jan 29, 2023
4439779
Better output colouring
BenjaminGuzman Jan 29, 2023
22358ca
Minor changes
BenjaminGuzman Jan 30, 2023
a6ac4be
Merge pull request #29 from BenjaminGuzman/dependabot/maven/org.junit…
BenjaminGuzman Jan 30, 2023
dbfe4db
Merge pull request #30 from BenjaminGuzman/dependabot/maven/org.jetbr…
BenjaminGuzman Jan 30, 2023
58b21d6
Merge pull request #31 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Jan 30, 2023
c50dd0a
Update maven.yml gh action to use java 17
BenjaminGuzman Jan 30, 2023
01a4fe4
Released v1.1.2
BenjaminGuzman Jan 30, 2023
b4b0448
Commands now accept multiple arguments
BenjaminGuzman Jan 30, 2023
7919bb1
Minor changes to help message
BenjaminGuzman Jan 31, 2023
c83ebb1
Minor change to a warning message
BenjaminGuzman Jan 31, 2023
9341961
Released v1.2.0
BenjaminGuzman Feb 1, 2023
2095ce5
Released v1.2.1
BenjaminGuzman Feb 1, 2023
29d8a1d
Bug fix with stop command
BenjaminGuzman Feb 5, 2023
79047b3
Updated README.md
BenjaminGuzman Feb 11, 2023
e5d054b
Bump maven-assembly-plugin from 3.4.2 to 3.5.0
dependabot[bot] Feb 23, 2023
ee78a97
Bump snakeyaml from 1.33 to 2.0
dependabot[bot] Feb 27, 2023
77d4e86
Bump maven-compiler-plugin from 3.10.1 to 3.11.0
dependabot[bot] Feb 27, 2023
41654e8
Bump json from 20220924 to 20230227
dependabot[bot] Feb 28, 2023
7ca26b9
Merge pull request #36 from BenjaminGuzman/dependabot/maven/org.yaml-…
BenjaminGuzman Mar 2, 2023
ad87517
Merge pull request #38 from BenjaminGuzman/dependabot/maven/org.json-…
BenjaminGuzman Mar 2, 2023
fa6619d
Merge pull request #37 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Mar 2, 2023
82f11f8
Merge pull request #35 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman Mar 2, 2023
d3d0a6c
Bump annotations from 24.0.0 to 24.0.1
dependabot[bot] Mar 3, 2023
a2f883b
Bump org.everit.json.schema from 1.14.1 to 1.14.2
dependabot[bot] Mar 10, 2023
7804375
Update README.md
BenjaminGuzman Mar 11, 2023
cdd7d61
Merge pull request #40 from BenjaminGuzman/dependabot/maven/com.githu…
BenjaminGuzman Mar 11, 2023
5bbc332
Bump maven-surefire-plugin from 3.0.0-M8 to 3.0.0
dependabot[bot] Mar 14, 2023
f6a5798
Bump picocli from 4.7.1 to 4.7.3
dependabot[bot] Apr 19, 2023
fe5668f
Bump junit-jupiter from 5.9.2 to 5.9.3
dependabot[bot] Apr 26, 2023
940251b
Minor changes to README.md and install.sh
BenjaminGuzman Apr 29, 2023
b4099da
Merge pull request #39 from BenjaminGuzman/dependabot/maven/org.jetbr…
BenjaminGuzman May 4, 2023
e24dcda
Merge pull request #41 from BenjaminGuzman/dependabot/maven/org.apach…
BenjaminGuzman May 4, 2023
59e4137
Merge pull request #43 from BenjaminGuzman/dependabot/maven/info.pico…
BenjaminGuzman May 4, 2023
01ba3dc
Merge pull request #44 from BenjaminGuzman/dependabot/maven/org.junit…
BenjaminGuzman May 4, 2023
8b8dde6
Fixed: Failed to identify Windows environment
BenjaminGuzman May 4, 2023
738255d
Merge remote-tracking branch 'origin/main'
BenjaminGuzman May 4, 2023
417f5d8
Fixed: process is not destroyed unless it is destroyed forcibly in Wi…
BenjaminGuzman May 5, 2023
339fa67
v1.2.2 released
BenjaminGuzman May 5, 2023
a7b2323
Bump org.json:json from 20230227 to 20231013
dependabot[bot] Jan 13, 2024
28c9c82
Merge pull request #51 from BenjaminGuzman/dependabot/maven/org.json-…
BenjaminGuzman Jan 13, 2024
44017b5
Bump org.junit.jupiter:junit-jupiter from 5.9.3 to 5.10.2
dependabot[bot] Feb 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
26 changes: 26 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDE's
**/.idea
**/.vscode
**/*.swp

# Other files
**/*.dia~
Expand Down
251 changes: 242 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,253 @@
# microstart
CLI utility to start processes.
CLI utility to start various processes in parallel with a start sequence.

If you are using a microservice architecture, this may come handy as it can various microservices
with just some simple lines.

This improves developer experience because you'll no longer need to open multiple terminals 🚀.
It improves developer experience because **you'll no longer need to open multiple terminals**.

It is similar to docker compose, but these are the main differences:

- This does not require a docker container to be built. Any command you run from command line can be run here
- It supports microservice chains (see below)
- Doesn't need docker installed. Any command you run from command line can be run by this program
- It supports process groups and dependencies<sup>1</sup>
- Can generate [graphviz code](https://graphviz.org/doc/info/lang.html) based on the configuration file

**It is intended to be used in development environment preferably**, since in production you have more pro stuff like
kubernetes.

<sup>1</sup> docker compose also supports dependencies via
[`depends_on`](https://docs.docker.com/compose/compose-file/#depends_on), but that works slightly different.

## Feature overview

- Start **group processes** defined in configuration
- Configure dependencies in order to **start a process after** another has notified **successful startup**
- Start **single processes** defined in configuration
- Generate [**graphviz code**](https://graphviz.org/doc/info/lang.html) from configuration to get an overview of the
dependency graph between your application microservices (or processes)

Here is a small demonstration

![Example](./microstart-example.gif)

Configuration file used in GIF is [example.json](./example.json) or [example.yml](./example.yml).

[schema.json](src/main/resources/schema.json) contains all configurable properties.

Notice that _Search engine_ service is run before anything else, then both _users_ and _crypto_ services run
concurrently, and, after both have notified successful startup, _Landing page_ is started.

Generated dependency graph image:

![Dependency graph for example](./example.svg)

## Concepts

### Microservice chain
### Process groups

Suppose your application has the following dependency graph

Bla bla bla...
![Dependency graph](dependency-graph-example.svg)

Then, we can define 4 groups:

1. Databases (Redis, Solr, PostgreSQL)
2. Microservices (Users, Login, Catalogs)
3. Gateway (Gateway)
4. Frontend (WebApp, AndroidApp, IOSApp)

Group 4 depends on group 3, which in turn depends on group 2, which in turn depends on group 1.
And it can be described with the following YAML configuration (JSON can be used too):

```yaml
services: [ ]
groups:
- name: Frontend
aliases:
- frontend
- front
services:
- angular
- android-client
- ios-client
dependencies:
- gateway

- name: Gateway
aliases:
- gate
- gateway
services:
- gateway
dependencies:
- microservices

- name: Microservices
aliases:
- microservices
services:
- users
- login
- catalogs
dependencies:
- databases

- name: Databases
aliases:
- databases
- db
- dbs
services:
- solr
- redis
- postgres

ignoreErrrors: true
```

As you can see, each group has:

- `name`: **required**. Name of the group. Can be used to start/stop the service group.
- `aliases`: Aliases for the name. Can be used to start/stop the service group.
- `services`: **required**. List of services that should run with this group. **references services defined in
the `services` array** (see below).
- `dependencies`: List of groups that should be started before this group is started.
The group will not start<sup>1</sup> unless its dependencies have successfully notified they have started

<sup>1</sup> You can modify this behaviour with the `ignoreErrors` key.

It is allowed to have a group and a service with the same name or alias, but not 2 groups or 2 services with the
same name or alias

### Process

The property `services` is where you define the actual processes that will run when a group starts.
Example:

```yaml
services:
- name: Web App
aliases:
- web-app
- angular
start: npm run start
color: 0xff0000
workDir: super-project/frontend/web
startedPatterns:
- '(service|server) is listening on https?://'
errorPatterns:
- Error (happened|occurred|in)
stdin: web-app-stdin.txt
stop: SIGTERM

- name: Android App
aliases:
- android-app
- android-client
start: echo Starting android client... Done.
color: 0x00ff00
workDir: super-project/frontend/android
startedPatterns:
- done

- name: IOS App
aliases:
- ios-app
- ios-client
start: echo Starting ios client... Done.
workDir: super-project/frontend/ios
startedPatterns:
- done

- name: Gateway
aliases:
- gateway
start: echo Starting gateway... Gateway is up and running.
workDir: super-project/frontend/android
startedPatterns:
- is up and running
stop: systemctl stop custom-gateway-service
stopTimeout: 1

- name: Users
aliases:
- users
start: node main.js
workDir: super-project/backend/users
startedPatterns:
- (service|server) is listening

groups:
- name: Frontend
aliases:
- frontend
- front
services:
- angular
- android-client
- ios-client
dependencies:
- gateway

- name: Gateway
aliases:
- gate
- gateway
services:
- gateway
dependencies:
- microservices

- name: Microservices
aliases:
- microservices
services:
- users
- login
- catalogs
dependencies:
- databases

- name: Databases
aliases:
- databases
- db
- dbs
services:
- solr
- redis
- postgres

ignoreErrors: true
```

For a full and detailed list of configurable properties of a service please see
[schema.json](src/main/resources/schema.json)

**Aliases and names are case-sensitive**, that's why *Gateway* has an alias *gateway*

**patterns** (`startedPatterns` and `errorPatterns`) **are case-insensitive**, and please note these patterns are
regular expressions (so, `inactive (dead)` is NOT the same as `inactive \(dead\)`)

**Once processes have started it is recommended to manage them inside microstart**. Don't manage processes externally
(e.g. manually sending signals with `kill` command), because you may end up with orphan processes.
A concrete example of this is when you use `npm start` as the start command. Killing the npm process may not kill the
nodejs process!

## YAML/JSON config properties

For all available JSON/YAML properties, description and constraints see [schema.json](src/main/resources/schema.json)

## Installation

[`install.sh`](install.sh) script is provided, simply execute it

## Dependencies

- [PicoCLI](https://picocli.info/): Parse CLI args and colorize output
- [Jetbrains Annotations](https://www.jetbrains.com/help/idea/annotating-source-code.html): Better code documentation
- [JUnit 5](https://junit.org/junit5/): Test framework
- [JSON parser](https://mvnrepository.com/artifact/org.json/json): Parse JSON
- [JSON schema validator](https://github.com/everit-org/json-schema/): Validate JSON with a defined schema
- [Snake YAML](https://bitbucket.org/asomov/snakeyaml/src): Convert from YAML (to `Map<String, Object>`) to JSON

## License

![GPLv3](gplv3.png)
6 changes: 6 additions & 0 deletions dependency-graph-example.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
digraph Example {
{WebApp[color=blue] AndroidApp[color=blue] IOSApp[color=blue]} -> Gateway
Gateway -> {Login[color=green] Users[color=green] Catalogs[color=green]}
{Login Users} -> {Redis[color=red] Solr[color=red]}
Catalogs -> {PostgreSQL[color=red]}
}
Loading