[Cluster Daemon] - Plug & Play Driver Support [part 2]
utopian-io·@samrg472·
0.000 HBD[Cluster Daemon] - Plug & Play Driver Support [part 2]
<center>  </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?  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/>
👍 samrg472, arbeitssuchend, martinasari, rickyyolanda86, steemdunk, jeanviete, civilianlife, greg07, matstaader, mstaader, astaader, linda-rose, victoria-harr, maimunah, rakibulih, yusmadi, gdfood, vitaundich, rayelite1, lahu, emonandels, cardinalkennedy, rayelite8, cardinalkpatrick, fifi-yanti, cardinalemil, mharr331, jamessvendsen, apocalypse612, prime-cleric, petrihuhtanen, primadono, canbethisone, gabbrielle, rosemary-k, selenascott, rasgriz311, abn, montedeilumi, khusairi, alfisyahrin, freddd009, belovebelight, cifer44, the-bishop-ufc, ewq, gijoge, rezaleoni, evie5el, polbot, diamondrich, therealwolf, cifer, ihtiht, gutzygwin, utopian-1up, flauwy, mahdiyari, simonluisi, stoodkev, ansonoxy, jamesbarraclough, family.app, maphics, helo, ronimm, jesdn16, espoem, odebgaming, nathalie13, not-a-bird, bitopia, evilest-fiend, proffgodswill, sweeverdev, yeswanth, howtosteem, roj, makrotheblack, thinkkniht, kslo, navx, sebastiengllmt, amosbastian, rhotimee, widiaendah, kid1412, nightdragon, opulence, dexter24, thatmemeguy, dyancuex, herman2141, mufasatoldyou, luisrod, parag, varja, dethclad, luoq, zlatkamrs, bobsthinking, acrywhif, layanmarissa, isacastillor, jerybanfield, deejee, rsteem, lemony-cricket, exploreand, photohunter1, photohunter2, photohunter3, photohunter4, photohunter5, paav, flinter, donjyde, wirdayulahya, pepememes, zay-arasi, gotgame, zoneboy, yourmercury, patatesyiyen, onin91, isabella394, zinonweke, petvalbra, olayhemy, sylinda, jbeguna04, livsky, badmusazeez, fai.zul, heshe-f, bluestorm, ilyastarar, jfuenmayor96, xtramedium, smafey, timmyeu, steaknsteem, masud222, zohaib715, anmeitheal, solomon507, emailbox19149, emirfirlar, rayday, kaking, josh26, fmbs25, aderemi01, killbill73, amirdesaingrafis, reazuliqbal, aliyu-s, crispycoinboys, daszod, animesukidesu, ozcanpolat, derasmo, anime.lovers, flugbot, steemlore, studytext, drigweeu, toninux, fabiocola, odibezeking, mrmaracucho, adol, jdc, devilonwheels, blaize-eu, steemassistant, fabinhocrypto, bargolis, phasma, mellissamartz, adhew, idlebright, jrmiller87, cashthekush, gwapoaller, genoner, portugalcoin, imranpase, utopian-io, palermo, rag.web, omjacknews, wackou, thehar, bishal3690, romankhan368, jannatritu,