Skip to content

Commit

Permalink
add files structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Dec 17, 2022
1 parent b3bace9 commit 3d4aa5e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
# foreman
# Foreman
It is a [foreman](https://github.com/ddollar/foreman) implementation in GO.

## Description
Foreman is a manager for [Procfile-based](https://en.wikipedia.org/wiki/Procfs) applications. Its aim is to abstract away the details of the Procfile format, and allow you to run your services directly.

## Features
- Run procfile-backed apps.
- Able to run with dependency resolution.

## Procfile
Procfile is simply `key: value` format like:
```yaml
app1:
cmd: ping -c 1 google.com
run_once: false
checks:
cmd: ps aux | grep google
deps:
- redis
app2:
cmd: ping -c 5 yahoo.com
checks:
cmd: ps aux | grep yahoo

redis:
cmd: redis-server --port 6010
checks:
cmd: redis-cli -p 6010 ping
tcp_ports: [6010]
```
**Here** we defined three services `app1`, `app2` and `redis` with check commands and dependency matrix

## How to use
**First:** modify the procfile with processes or services you want to run.

**second**: Simply run with command:
```sh
$ ./foreman
```

1 change: 1 addition & 0 deletions cmd/foreman/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main
1 change: 1 addition & 0 deletions foreman.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package foreman
2 changes: 2 additions & 0 deletions foreman_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package foreman

1 change: 1 addition & 0 deletions internal/depgraph/depgraph.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package depgraph
1 change: 1 addition & 0 deletions internal/procparser/procfile_parser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package procparser
19 changes: 19 additions & 0 deletions test-procfiles/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
service_ping:
cmd: ping -c 2 google.com | grep google
checks:
cmd: ls
deps:
- service_redis

service_sleep:
cmd: sleep 5
checks:
cmd: ls
deps:
- service_ping

service_redis:
cmd: redis-server --port 6010
run_once: true
checks:
cmd: redis-cli -p 6010 ping
1 change: 1 addition & 0 deletions test-procfiles/Procfile-bad-test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is invalid Procfile syntax, Procfile must be yaml file.
15 changes: 15 additions & 0 deletions test-procfiles/Procfile-cyclic-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sleeper:
run_once: true
cmd: sleep infinity
checks:
cmd: ls
tcp_ports: [4759, 1865]
udp_ports: [4500, 3957]
deps:
- hello

hello:
run_once: true
cmd: echo "hello"
deps:
- sleeper
13 changes: 13 additions & 0 deletions test-procfiles/Procfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sleeper:
run_once: true
cmd: sleep infinity
checks:
cmd: ls
tcp_ports: [4759, 1865]
udp_ports: [4500, 3957]
deps:
- hello

hello:
run_once: true
cmd: echo "hello"

0 comments on commit 3d4aa5e

Please sign in to comment.