Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit f393ad5

Browse files
committed
Docs: Add documentation
1 parent 3531336 commit f393ad5

1 file changed

Lines changed: 140 additions & 2 deletions

File tree

README.md

Lines changed: 140 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,140 @@
1-
# devcontrol
2-
Development Environment Control Script
1+
# Development Environment Control Script
2+
3+
Simply dev env control script writen in BASH
4+
5+
## Objective
6+
7+
You may be tired of executing the same sentences in order, over and over again, to perform the same task.
8+
9+
The `devcontrol` script can help by calling your set of scripts that automate these tasks, such as starting or stopping services, loading initial data, putting everything together in a single dynamic management interface and allowing you to keep the focus on your development work.
10+
11+
## Usage
12+
13+
1. Put the `devcontrol.sh` script somewhere in your path an make it executable. I suggest you to put it under `/usr/local/bin` naming it`devcontrol`, or put in a directory of your project in `bin/devcontrol.sh`.
14+
2. Create a directory called `devcontrol/actions` im the root directory of your project and put your action scripts (one bash script file per action) within.
15+
3. Optionally, create another directory called `devcontrol/global` and put a bash script called `startup.sh` with your initialization variables and global functions.
16+
4. Execute the `devcontrol` script in the root folder of your project.
17+
18+
The `devcontrol` script will collect the whole of your action scripts and put enable you to execute as parametrized options of the `devcontrol` script.
19+
20+
Find an example under `examples/docker` folder. Is a set of scripts to manage project driven by docker-compose.
21+
22+
```console
23+
$ mkdir bin
24+
$ rsync -avpP ~/devcontrol/devcontrol.sh bin
25+
sending incremental file list
26+
devcontrol.sh
27+
5,452 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/1)
28+
29+
sent 5,574 bytes received 35 bytes 11,218.00 bytes/sec
30+
total size is 5,452 speedup is 0.97
31+
$ rsync -avpP ~/devcontrol/examples/docker/devcontrol/ devcontrol/
32+
sending incremental file list
33+
created directory devcontrol
34+
./
35+
actions/
36+
actions/destroy.sh
37+
889 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=6/10)
38+
actions/enter.sh
39+
974 100% 951.17kB/s 0:00:00 (xfr#2, to-chk=5/10)
40+
actions/logs.sh
41+
810 100% 791.02kB/s 0:00:00 (xfr#3, to-chk=4/10)
42+
actions/start.sh
43+
823 100% 803.71kB/s 0:00:00 (xfr#4, to-chk=3/10)
44+
actions/status.sh
45+
885 100% 864.26kB/s 0:00:00 (xfr#5, to-chk=2/10)
46+
actions/stop.sh
47+
814 100% 794.92kB/s 0:00:00 (xfr#6, to-chk=1/10)
48+
global/
49+
global/startup.sh
50+
654 100% 638.67kB/s 0:00:00 (xfr#7, to-chk=0/10)
51+
52+
sent 6,474 bytes received 197 bytes 4,447.33 bytes/sec
53+
total size is 5,849 speedup is 0.88
54+
$ find devcontrol/
55+
devcontrol/
56+
devcontrol//actions
57+
devcontrol//actions/logs.sh
58+
devcontrol//actions/enter.sh
59+
devcontrol//actions/status.sh
60+
devcontrol//actions/destroy.sh
61+
devcontrol//actions/stop.sh
62+
devcontrol//actions/start.sh
63+
devcontrol//global
64+
devcontrol//global/startup.sh
65+
$ bin/devcontrol.sh
66+
Devcontrol Docker Example (c) 2019
67+
68+
Usage:
69+
- bin/devcontrol.sh help # This information page
70+
- bin/devcontrol.sh destroy # Environment removal
71+
- bin/devcontrol.sh enter # Enter with a console to a service: 'app' (default), 'db' or 'duing'
72+
- bin/devcontrol.sh logs # Show logs
73+
- bin/devcontrol.sh start # Environment start and load initial data
74+
- bin/devcontrol.sh status # Get status of the local docker development environment
75+
- bin/devcontrol.sh stop # Platform stop
76+
77+
Use 'bin/devcontrol.sh help <action>' to display his help (e.g. bin/devcontrol.sh help destroy)
78+
79+
$ bin/devcontrol.sh help status
80+
Devcontrol Docker Example (c) 2019
81+
82+
Help for the 'status' action
83+
84+
Execute the 'docker-compose ps' command
85+
$ bin/devcontrol.sh status
86+
Devcontrol Docker Example (c) 2019
87+
88+
Name Command State Ports
89+
----------------------------------------------------------------------------------
90+
pedidos_app_1 /var/www/pedidos/bin/app.sh Up 0.0.0.0:10080->80/tcp
91+
pedidos_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:13306->3306/tcp
92+
pedidos_duing_1 /bin/bash /root/startup.sh Up 0.0.0.0:13389->3389/tcp
93+
pedidos_waiter_1 /usr/local/bin/entrypoint.sh Exit 0
94+
```
95+
96+
## Action scripts format
97+
98+
The `devcontrol` script will call your scripts with at least one parameter identified in the $1 variable within your script and one of the following texts:
99+
100+
- `brief`: Expect that the script will display one line with a summary exmplanation of the comand. It will be used in the action list (`devcontrol help`)
101+
- `help`: Expect a multiline explanation. It will be used with the (`devcontrol help <action>`)
102+
- `exec`: The statements of the action (`devcontrol <action>`). The script will receive parameters from the `devcontrol` script.
103+
104+
Take a look at the example actions under `examples/docker/actions` folder. Feel free to add your own examples as pull request to this project.
105+
106+
## Startup script format
107+
108+
It's up to you. It will be executed first, so you can put here the title of your project.
109+
110+
## Debug
111+
112+
Execute the script with `DC_DEBUG=1 devcontrol status` to help trace errors.
113+
114+
```console
115+
$ DC_DEBUG=1 bin/devcontrol.sh
116+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: begin
117+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: Devcontrol (c) Teecke 2019
118+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: Startup
119+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: Execute delegate startup with 'devcontrol/global/startup.sh' script
120+
Devcontrol Docker Example (c) 2019
121+
122+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: Load action list from 'devcontrol/actions' directory
123+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'destroy'
124+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'enter'
125+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'logs'
126+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'start'
127+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'status'
128+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: - Found action 'stop'
129+
>>>> DEBUG >>>>> 2019-08-24 19:32:31 devcontrol: Located 6 actions
130+
Usage:
131+
- bin/devcontrol.sh help # This information page
132+
- bin/devcontrol.sh destroy # Environment removal
133+
- bin/devcontrol.sh enter # Enter with a console to a service: 'app' (default), 'db' or 'duing'
134+
- bin/devcontrol.sh logs # Show logs
135+
- bin/devcontrol.sh start # Environment start and load initial data
136+
- bin/devcontrol.sh status # Get status of the local docker development environment
137+
- bin/devcontrol.sh stop # Platform stop
138+
139+
Use 'bin/devcontrol.sh help <action>' to display his help (e.g. bin/devcontrol.sh help destroy)
140+
```

0 commit comments

Comments
 (0)