Skip to content

Commit 09ea594

Browse files
committed
update readme
1 parent dcb19bc commit 09ea594

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,31 @@ TagIt is a tool that updates Consul service registration tags with outputs of a
88

99
## Table of Contents
1010

11-
- [Why TagIt?](#why)
11+
- [Why TagIt?](#why-tagit)
1212
- [Installation](#installation)
1313
- [Usage](#usage)
14+
- [Run Command](#run-command)
15+
- [Cleanup Command](#cleanup-command)
16+
- [Systemd Command](#systemd-command)
1417
- [How It Works](#how-it-works)
1518
- [Examples](#examples)
1619
- [Contributing](#contributing)
1720
- [License](#license)
1821

19-
## Why?
22+
## Why TagIt?
2023

2124
TagIt addresses a feature that's currently missing from Consul. You can read more about the need for this functionality in [this Consul issue](https://github.com/hashicorp/consul/issues/1048).
2225

2326
Here are some scenarios where TagIt can be useful:
2427

25-
1. **Database Leader Tagging**: Your databases are under `mydb.service.consul`, and you want to ensure all writes go to the leader.
26-
- Run a script that checks for the leader and updates the tag accordingly.
27-
28-
2. **Non-Consul-Aware Service Discovery**: You have a service that isn't Consul-aware, but you want to use Consul for service discovery.
29-
- Run a script that checks the service status and updates the tags.
30-
31-
3. **Web Server VHost Tagging**: You have a load balancer or web server, and you want tags for all vhosts served by this server.
32-
- Run a script that checks the vhosts and updates the tags.
33-
34-
4. **Generic Service Tagging**: For any services that aren't Consul-aware, but you want to use Consul for service discovery.
35-
- Run a script that checks the service and updates the tags.
28+
1. **Database Leader Tagging**: Ensure all writes go to the leader by tagging it appropriately.
29+
2. **Non-Consul-Aware Service Discovery**: Use Consul for service discovery with services that aren't Consul-aware.
30+
3. **Web Server VHost Tagging**: Tag all vhosts served by a web server or load balancer.
31+
4. **Generic Service Tagging**: Tag any services for Consul-based service discovery.
3632

3733
## Installation
3834

39-
To install TagIt, you can use the following commands:
35+
To install TagIt, use the following commands:
4036

4137
```bash
4238
$ git clone https://github.com/ncode/tagit
@@ -46,7 +42,7 @@ $ go build
4642

4743
## Usage
4844

49-
TagIt provides two main commands: `run` and `cleanup`.
45+
TagIt provides three main commands: `run`, `cleanup`, and `systemd`.
5046

5147
### Run Command
5248

@@ -64,19 +60,30 @@ The `cleanup` command removes all tags with the specified prefix from the servic
6460
$ ./tagit cleanup --consul-addr=127.0.0.1:8500 --service-id=my-service1 --tag-prefix=tagit
6561
```
6662

63+
### Systemd Command
64+
65+
The `systemd` command generates a systemd service file for TagIt:
66+
67+
```bash
68+
./tagit systemd --service-id=my-service1 --script=./examples/tagit/example.sh --tag-prefix=tagit --interval=5s --user=tagit --group=tagit
69+
```
70+
71+
This command will output a systemd service file that you can use to run TagIt as a system service.
72+
6773
## How It Works
6874

69-
Here's a sequence diagram illustrating how TagIt interacts with Consul:
75+
TagIt interacts with Consul as follows:
7076

7177
>>>>>>> 6a3e346 (update readme)
7278
```mermaid
7379
sequenceDiagram
7480
participant tagit
7581
participant consul
7682
loop execute script on interval
77-
tagit->>consul: Do you have a service with id my-service1?
78-
consul->>tagit: Yes, here it is and that's the current registration
79-
tagit->>consul: Update current registration adding or removing prefixed tags with the output of the script
83+
tagit->>consul: Query service with ID
84+
consul->>tagit: Return current service registration
85+
tagit->>tagit: Execute script and process output
86+
tagit->>consul: Update service registration with new tags
8087
end
8188
```
8289

@@ -99,7 +106,12 @@ Here's an example of how to test TagIt:
99106
./tagit run --consul-addr=127.0.0.1:8500 --service-id=my-service1 --script=./examples/tagit/example.sh --interval=5s --tag-prefix=tagit
100107
```
101108

102-
4. Clean up the tags:
109+
4. Generate a systemd service file:
110+
```bash
111+
./tagit systemd --service-id=my-service1 --script=./examples/tagit/example.sh --tag-prefix=tagit --interval=5s --user=tagit --group=tagit > /etc/systemd/system/tagit-my-service1.service
112+
```
113+
114+
5. Clean up the tags:
103115
```bash
104116
./tagit cleanup --consul-addr=127.0.0.1:8500 --service-id=my-service1 --tag-prefix=tagit
105117
```

0 commit comments

Comments
 (0)