create account

[Cluster Daemon] - Plug & Play Driver Support [part 2] by samrg472

View this thread on: hive.blogpeakd.comecency.com
· @samrg472 · (edited)
$95.38
[Cluster Daemon] - Plug & Play Driver Support [part 2]
<center>
![](https://res.cloudinary.com/hpiynhbhq/image/upload/v1519760075/um5d3en5ufohwshmcdx3.jpg)
</center>
<center>
([Source](https://www.kom.tu-darmstadt.de/fileadmin/_migrated/pics/SW_Cluster_Logo_01.jpg))
</center>

## Introduction

Clustd is an open source cluster management provider. The goal is to provide automated failover systems for apps, whether the system is down for maintenance or an unexpected event. When the system is ready, it will deployed in production on @steemdunk to minimize any form of downtime for the bot and web services.

*Disclaimer:* This is not intended to be used in conjunction with a database, otherwise data will be out of sync. See your database manual for setting up clusters that will preserve the integrity of your database across multiple machines.

## What does a cluster look like?

![](https://res.cloudinary.com/hpiynhbhq/image/upload/v1520015918/c1m12puyk8rnvszdahxb.png)

Each machine runs a clustd daemon. The daemon provides automatic consensus on deciding a new master if the master goes down. Drivers control what actions to perform when this happens.

## Drivers

A driver is what controls the server when a specific machine becomes a master or is no longer a master. It does not provide its own server like a cluster daemon and connects directly to the cluster machine directly. It is expected to run alongside the cluster daemon on the same machine. Multiple drivers can connect to the cluster daemon to perform multiple actions specific to that driver.

There is now an API for driver implementations. clustd has been refactored and now has its own [clustd-lib](https://github.com/steemdunk/clustd-lib) library.

A sample driver implementation
```
export class TestDriver extends DriverMachine {

  constructor(dc: DriverClient, host: string) {
    super(dc, host);
  }

  trigger(isMaster: boolean): void {
    console.log('Master status:', isMaster);
  }
}
```

Connecting to the cluster
```
(async () => {
  const dc: DriverClient = {
    secret: 'cluster communication secret',
    id: 'driver-test-' + crypto.randomBytes(4).readUInt32BE(0),
  }
  const dm = new BashDriver(dc, 'ws://127.0.0.1:3001');
  await dm.connect();
})();
```

Drivers will automatically reconnect to the cluster daemon if the daemon was taken offline. No further action is required in the implementation. The ID should always be unique in case multiple drivers of the same implementation is running. In the future this may done automatically or with a different approach and strategy.

This API is a work in progress but the initial framework is now here. This is a leap forward towards creating the bash driver.

## Roadmap and ideas

The next part will have a functional bash driver. There could be additional drivers written to provide notifications, whether email or SMS. Providing a sort of monitoring framework of the cluster status and what happened.

## Relevant commits

- [clustd-lib driver API](https://github.com/steemdunk/clustd-lib/commit/63bd4bcc408a8811c1ef9fc7afe34adb463efcc2)
- [Refactor clustd to use clustd-lib](https://github.com/steemdunk/clustd/commit/53c0592c1edbc1b857e44b9d331bcb9506ed37d6)
- [Support driver connections in clustd](https://github.com/steemdunk/clustd/commit/d9e679a8bf7c2323c326abc82d0937f9519d1645)
<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@samrg472/cluster-daemon-plug-and-play-driver-support-part-2">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 133 others
properties (23)
authorsamrg472
permlinkcluster-daemon-plug-and-play-driver-support-part-2
categoryutopian-io
json_metadata{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":123172902,"name":"clustd","full_name":"steemdunk/clustd","html_url":"https://github.com/steemdunk/clustd","fork":false,"owner":{"login":"steemdunk"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","opensource","dev","technology","javascript"],"users":["steemdunk","samrg472"],"links":["https://www.kom.tu-darmstadt.de/fileadmin/_migrated/pics/SW_Cluster_Logo_01.jpg","https://github.com/steemdunk/clustd-lib","https://github.com/steemdunk/clustd-lib/commit/63bd4bcc408a8811c1ef9fc7afe34adb463efcc2","https://github.com/steemdunk/clustd/commit/53c0592c1edbc1b857e44b9d331bcb9506ed37d6","https://github.com/steemdunk/clustd/commit/d9e679a8bf7c2323c326abc82d0937f9519d1645"],"moderator":{"account":"ms10398","time":"2018-03-03T09:06:31.579Z","reviewed":true,"pending":false,"flagged":false},"questions":[],"score":0}
created2018-03-02 18:54:54
last_update2018-03-03 09:06:30
depth0
children12
last_payout2018-03-09 18:54:54
cashout_time1969-12-31 23:59:59
total_payout_value68.553 HBD
curator_payout_value26.829 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,471
author_reputation8,524,113,165,873
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,698,929
net_rshares26,034,873,784,200
author_curate_reward""
vote details (197)
@abn ·
Sam, this is excellent work you do with Utopain IO! Keep it up!
properties (22)
authorabn
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180305t232212940z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-03-05 23:22:27
last_update2018-03-05 23:22:27
depth1
children0
last_payout2018-03-12 23:22:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length63
author_reputation6,507,300,897,068
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,484,669
net_rshares0
@belovebelight ·
https://media.giphy.com/media/vCKC987OpQAco/giphy.gif
<a href="https://giphy.com/gifs/funny-celebrity-bill-murray-vCKC987OpQAco">Source</a>
properties (22)
authorbelovebelight
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180302t204207760z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"image":["https://media.giphy.com/media/vCKC987OpQAco/giphy.gif"],"links":["https://giphy.com/gifs/funny-celebrity-bill-murray-vCKC987OpQAco"],"app":"steemit/0.1"}
created2018-03-02 20:42:09
last_update2018-03-02 20:42:09
depth1
children0
last_payout2018-03-09 20:42:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length139
author_reputation5,707,294,679,323
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,717,777
net_rshares0
@cifer44 ·
This would be great!
properties (22)
authorcifer44
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180302t213746752z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-03-02 21:37:51
last_update2018-03-02 21:37:51
depth1
children0
last_payout2018-03-09 21:37:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length20
author_reputation5,751,224,533,395
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,726,932
net_rshares0
@diamondrich ·
This is a great ideal if implemented
properties (22)
authordiamondrich
permlinkre-samrg472-201832t21399408z
categoryutopian-io
json_metadata{"tags":["utopian-io","opensource","dev","technology","javascript"],"app":"esteem/1.5.0","format":"markdown+html","community":"esteem"}
created2018-03-02 20:39:15
last_update2018-03-02 20:39:15
depth1
children0
last_payout2018-03-09 20:39:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation1,715,031,577,245
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries
0.
accountesteemapp
weight500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,717,246
net_rshares0
@ms10398 ·
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/uTyJkNm).

**[[utopian-moderator]](https://utopian.io/moderators)**
properties (22)
authorms10398
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180303t090639201z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-03-03 09:06:39
last_update2018-03-03 09:06:39
depth1
children0
last_payout2018-03-10 09:06:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length173
author_reputation27,572,487,973,390
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,838,223
net_rshares0
@muhammadazzikra ·
THANK YOU FOR THIS INCREDIBLE INFORMATION
properties (22)
authormuhammadazzikra
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180305t124154953z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"busy","app":"busy/2.4.0"}
created2018-03-05 12:41:57
last_update2018-03-05 12:41:57
depth1
children0
last_payout2018-03-12 12:41:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation319,634,092,040
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,370,303
net_rshares0
@muhammadazzikra ·
THANK YOU FOR THIS INCREDIBLE INFORMATION
properties (22)
authormuhammadazzikra
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180306t064804731z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-03-06 06:48:12
last_update2018-03-06 06:48:12
depth1
children0
last_payout2018-03-13 06:48:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation319,634,092,040
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,557,654
net_rshares0
@pukhtoon ·
hey rex I will be appreciated if you vote on my comment.
properties (22)
authorpukhtoon
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180304t151739331z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-03-04 15:17:39
last_update2018-03-04 15:17:39
depth1
children0
last_payout2018-03-11 15:17:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length56
author_reputation-733,536,996,232
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,154,306
net_rshares0
@rayelite1 ·
Great post @samrg472!
properties (22)
authorrayelite1
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180302t204209958z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["samrg472"],"app":"steemit/0.1"}
created2018-03-02 20:42:12
last_update2018-03-02 20:42:12
depth1
children0
last_payout2018-03-09 20:42:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length21
author_reputation1,320,087,904,066
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,717,797
net_rshares0
@utopian-1up ·
<div class="pull-left">

![1UP-Kayrex_tiny.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515383984/ekyf2thxg7j2t0qro1h3.png)

</div>

<div class="text-justify">


### You've got upvoted by <code>Utopian-1UP</code>!
You can give up to ten [1UP](https://steemit.com/utopian-io/@steem-plus/steemplus-2-4-utopian-1up-is-here)'s to Utopian posts every day after they are accepted by a Utopian moderator and before they are upvoted by the official @utopian-io account. Install the @steem-plus browser extension to use 1UP. By following the 1UP-trail using [SteemAuto](https://steemauto.com/) you support great Utopian authors and earn high curation rewards at the same time. 

<hr>

1UP is neither organized nor endorsed by Utopian.io!

</div>
properties (22)
authorutopian-1up
permlink20180303t190836564z
categoryutopian-io
json_metadata{"app":"1up"}
created2018-03-03 19:08:36
last_update2018-03-03 19:08:36
depth1
children0
last_payout2018-03-10 19:08:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length764
author_reputation2,324,758,056,093
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id41,940,612
net_rshares0
@utopian-io ·
### Hey @samrg472 I am @utopian-io. I have just upvoted you!
#### Achievements
- WOW WOW WOW People loved what you did here. GREAT JOB!
- You have less than 500 followers. Just gave you a gift to help you succeed!
- Seems like you contribute quite often. AMAZING!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180304t094645088z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-03-04 09:48:24
last_update2018-03-04 09:48:24
depth1
children0
last_payout2018-03-11 09:48:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,141
author_reputation152,955,367,999,756
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,093,470
net_rshares0
@victoria-harr ·
Super cool sam!
properties (22)
authorvictoria-harr
permlinkre-samrg472-cluster-daemon-plug-and-play-driver-support-part-2-20180305t232653534z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-03-05 23:26:57
last_update2018-03-05 23:26:57
depth1
children0
last_payout2018-03-12 23:26:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length15
author_reputation3,602,715,849,795
root_title"[Cluster Daemon] - Plug & Play Driver Support [part 2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,485,336
net_rshares0