Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds init script for multi and single service and update readme #11

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
## Ballot

Consul service election with tagging support and hooks
Consul based leader election with tagging support and hooks

### What is it?

Consul doesn't support leader election for registered services. This tool is meant to help with that.
The idea is that you have multiple services and you need to select a leader. It will apply a tag of choise
to the leader and when a election happens you can hook a script execution.
This tool can be very useful for setups that require a leader service, but do not offer a leader election out of the box.
Consul lacks a built-in feature for leader election among registered services. This tool is designed to fill that gap. It functions by designating a leader among multiple services, marking the chosen leader with a specified tag. Additionally, it allows for the execution of a script whenever a leader election occurs.

### How do I test it?

Expand Down
26 changes: 26 additions & 0 deletions init/ballot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[Unit]
Description=Consul based leader election with tagging support and hooks
After=network.target local-fs.target remote-fs.target nss-lookup.target time-sync.target

[Service]
User=ballot
Group=ballot
ProtectSystem=full
PrivateTmp=yes
PrivateDevices=yes
EnvironmentFile=-/etc/sysconfig/ballot
ExecStart=/usr/bin/ballot run --config=/etc/ballot/ballot.yaml $CMD_OPTS
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StartLimitInterval=60
StartLimitBurst=3
LimitNOFILE=65536
LimitMEMLOCK=infinity
SyslogIdentifier=ballot

[Install]
WantedBy=multi-user.target
26 changes: 26 additions & 0 deletions init/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[Unit]
Description=Consul based leader election with tagging support and hooks
After=network.target local-fs.target remote-fs.target nss-lookup.target time-sync.target

[Service]
User=ballot
Group=ballot
ProtectSystem=full
PrivateTmp=yes
PrivateDevices=yes
EnvironmentFile=-/etc/sysconfig/ballot-%i
ExecStart=/usr/bin/ballot run --config=/etc/ballot/%i.yaml $CMD_OPTS
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StartLimitInterval=60
StartLimitBurst=3
LimitNOFILE=65536
LimitMEMLOCK=infinity
SyslogIdentifier=ballot-%i

[Install]
WantedBy=multi-user.target