Go daemon 微服务架构前期 ,服务高可用解决方案

简介

微服务架构前期 ,服务高可用解决方案。

  • 服务名称:

点击图片,进入可视化编辑

配置

config.yaml

位置: /conf/config.yaml

  • SERVER 服务名称
  • PUBLIC_CONF 公共配置文件地址
  • SERVER_PORT 服务端口

services.json

位置: /conf/services.json

  • name 服务名称
  • priority 优先级
  • isInit 是否属于初始化服务 (如果为true 优先级高于所有 为false的服务)
  • isDaemon 是否守护进程(如果 false 仅godaemon 服务启动时拉起一次)
  • script 脚本
    • execPath 脚本执行路径
    • programFilePath 执行程序路径 程序自动拼接 公共工作路径(公共配置中的rootpath)
    • startCommand 启动指令
    • stopCommand 停止指令
  • healthCheck 保活验证
    • isHealthCheck 是否启用此验证
    • interval 运行状况检查将在容器启动后首先运行interval秒,然后在每次之前的检查完成后再次运行interval秒
    • start_period 为需要时间引导的容器提供初始化时间。在此期间的探测失败将不计入最大重试次数。但是,如果在启动期间健康检查成功,则认为容器已启动,所有连续失败都将计入最大重试次数。
    • retries 重试次数

API

服务配置

获取服务配置列表
GET /serviceInfo/get HTTP/1.1
{
  "data": [
    {
      "name": "godbproxy",
      "priority": 3,
      "isInit": false,
      "isDaemon": true,
      "script": {
        "execPath": "../godbproxy/run.sh",
        "programFilePath": "/godbproxy/godbproxy",
        "startCommand": "start",
        "stopCommand": "stop"
      },
      "healthCheck": {
        "isHealthCheck": true,
		....
    }
  ],
  "msg": "SUCCESS"
}
获取单个服务配置
GET /serviceInfo/find?name=godbproxy HTTP/1.1
{
  "data": {
    "name": "godbproxy",
    "priority": 3,
    "isInit": false,
    "isDaemon": true,
    "script": {
      "execPath": "../godbproxy/run.sh",
      "programFilePath": "/godbproxy/godbproxy",
      "startCommand": "start",
      "stopCommand": "stop"
    },
    "healthCheck": {
      "isHealthCheck": true,
     ....
    }
  },
  "msg": "SUCCESS"
}
更新或者增加服务配置
POST /serviceInfo/set HTTP/1.1
content-type: application/json

{
        "name":"godbproxy" ,
        "priority":3 ,
        "isInit":false,
        "isDaemon":true,
        "script":{
            "execPath":"../godbproxy/run.sh" ,
            "programFilePath":"/mnt/e/project/godbproxy/godbproxy" , 
            "startCommand":"start" , 
            "stopCommand":"stop"
        },
        "healthCheck":{
            "isHealthCheck":true ,
        ...
        }
}
删除单个服务配置
DELETE /serviceInfo/del?name=godbproxy HTTP/1.1

任务配置

获取任务列表
GET /task/get HTTP/1.1
{
  "data": [
    {
      "ServiceInfo": {
        "name": "godbproxy",
        "priority": 3,
        "isInit": false,
        "isDaemon": true,
        "script": {
          "execPath": "../godbproxy/run.sh",
          "programFilePath": "/godbproxy/godbproxy",
          "startCommand": "start",
          "stopCommand": "stop"
        },
        "healthCheck": {
          "isHealthCheck": true,
         ...
          }
        }
      },
      "State": 2,
      "StartFaultNum": 0,
      "StopFaultNum": 0,
      "Pids": [
        771
      ]
    }
  ],
  "msg": "SUCCESS"
}
获取单个任务
GET /task/find?name=godbproxy HTTP/1.1
{
  "data": {
    "ServiceInfo": {
      "name": "godbproxy",
      "priority": 3,
      "isInit": false,
      "isDaemon": true,
      "script": {
        "execPath": "../godbproxy/run.sh",
        "programFilePath": "/godbproxy/godbproxy",
        "startCommand": "start",
        "stopCommand": "stop"
      },
      "healthCheck": {
        "isHealthCheck": true,
        ...
      }
    },
    "State": 2,
    "StartFaultNum": 0,
    "StopFaultNum": 0,
    "Pids": [
      771
    ]
  },
  "msg": "SUCCESS"
}
更新或者增加任务
POST /task/set HTTP/1.1
content-type: application/json

{
        "name":"godbproxy" ,
        "priority":3 ,
        "isInit":false,
        "isDaemon":true,
        "script":{
            "execPath":"../../godbproxy/run.sh" ,
            "programFilePath":"/mnt/e/project/godbproxy/godbproxy" , 
            "startCommand":"start" , 
            "stopCommand":"stop"
        },
        "healthCheck":{
            "isHealthCheck":true ,
          ...
        }
}
删除任务
DELETE /task/del?name=godbproxy HTTP/1.1

运行

  1. git clone https://github.com/qingolang/godaemon.git
  2. cd godaemon
  3. 修改 conf/config.yaml
  4. 完善 services.json 要守护的服务
  5. 项目根目录下运行以下指令
  go mod tidy
  go build 
  ./run.sh start 
Similar Resources

Minimalistic paste daemon written in golang

Minimalistic paste daemon written in golang

Dec 4, 2022

daemon for removing torrents from deluge after a specified timeframe

deluge-remove-after -- daemon for removing torrents from deluge after a specified timeframe Table of Contents Why Installation Docker Build from sourc

Jul 10, 2022

shoutrrr daemon

shoutrrr daemon Orginal repositories: shoutrrr repository shoutrrr documentation Installation & Configuration Create a services.yaml with the followin

Dec 12, 2021

Secure Time Sync Daemon

stsd - Secure Time Sync Daemon ============================== Set system date based on HTTP 'date' headers over TLS. Inspired by Whonix's sdwdate, an

Dec 15, 2021

Aidos Kuneen (v2 network) daemon program that is controlled through the command line and remotely via RPC calls

adk-daemon: aidosd.v2 aidosd (v2) is a deamon which acts as bitcoind for adk. This version has been built specifically for network mesh version 2+ For

Dec 1, 2021

Golang daemon to update i3 workspace icons

i3-icons-daemon Is a lightweight golang daemon service that updates your i3 workspace based on the programs that are running in your workspace's windo

Jul 29, 2022

A daemon that has the purpose of installing and removing policies as they are laid in a specific directory

selinuxd This a daemon that has the purpose of installing and removing policies as they are laid in a specific directory. This directory is /etc/selin

Dec 14, 2022

gofrrsockets is a client library used to interact with FRR's daemon UNIX sockets

gofrrsockets gofrrsockets is a client library that can be used to send commands to FRR's daemon UNIX sockets. The library provides a safer (forking cm

Jun 13, 2022

Namecoin calendar notification daemon (ICS, CalDAV)

nccald nccald is a simple daemon to provide calendar notifications for Namecoin name expirations. The daemon periodically queries a Namecoin Core inst

Dec 11, 2021

DNS synchronization daemon for the AIRE project.

dns-sync Database structure: { "name": "example-host.example.com", "content": "127.1.33.7" } ENV parameters: DEBUG: true|false DNS_FILTER: Reg

Dec 20, 2021

Bastionzeros Agent and Daemon!

Bzero Bastionzero Bastionzero is a simple to use zero trust access SaaS for dynamic cloud environments. Bastionzero is the most secure way to lock dow

Oct 12, 2022

NDP Proxy + Responder daemon

PNDPD - NDP Responder + Proxy Features Efficiently process incoming packets using bpf (which runs in the kernel) Respond to all NDP solicitations on a

Dec 23, 2022

A proof-of-concept project that makes accessible buildkitd daemon from macOS

buildkit-machine buildkit-machine allows you to make buildkitd daemon accessible in your macOS environment. To do so, it uses lima, which is a Linux s

Dec 21, 2022

A daemon to make your keyboard backlight smart.

keyboard-backlight-daemon A daemon to make your keyboard backlight smart. Features Light up keyboard backlight based on user interaction (keyboard, mo

Jan 17, 2022

Wrapper for Lightning Network Daemon (lnd). It provides separate accounts with minimum trust for end users.

LndHub.go Wrapper for Lightning Network Daemon (lnd). It provides separate accounts with minimum trust for end users. LndHub compatible API implemente

Dec 21, 2022

The wazuh-integratord is a daemon that allows Wazuh to connect to external APIs and alerting tools such as Slack, VirusTotal and PagerDuty.

The wazuh-integratord is a daemon that allows Wazuh to connect to external APIs and alerting tools such as Slack, VirusTotal and PagerDuty.

Apr 22, 2022

This is a POC for a Falco Plugin allowing to gather events from a locale docker daemon.

Docker Events Plugin This is a POC for a Falco Plugin allowing to gather events from a locale docker daemon. ⚠️ This is a POC, don't use in Production

Apr 15, 2022

Openbazaar-go - OpenBazaar Server Daemon in Go

Openbazaar-go - OpenBazaar Server Daemon in Go

openbazaar-go OpenBazaar Server Daemon in Go This repository contains the OpenBa

Feb 15, 2022

nerdctl daemon (Docker API)

nerdctl daemon (Docker API)

nerdctld This is a daemon offering a nerdctl.sock endpoint. It can be used with DOCKER_HOST=unix://nerdctl.sock. Normally the nerdctl tool is a CLI-on

Dec 15, 2022
An autocompletion daemon for the Go programming language
An autocompletion daemon for the Go programming language

An autocompletion daemon for the Go programming language VERY IMPORTANT: this project is not maintained anymore, look for alternatives or forks if you

Jan 7, 2023
dyndns client daemon

README for dyndnscd =================== dyndnscd is the dyndns client daemon. It is a daemon that continually polls for IP address changes an in the

Sep 29, 2021
Resolver (DNS) cache daemon.
Resolver (DNS) cache daemon.

RESCACHED(1) Manual Page NAME rescached - DNS resolver cache daemon. Table of Contents SYNOPSIS OPTIONS DESCRIPTION FEATURES BEHIND THE DNS HOW CACHE

Nov 17, 2022
A simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys.
A simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys.

ipfs-sync is a simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys, so you can always access your directories from the same address. You can use it to sync your documents, photos, videos, or even a website!

Dec 30, 2022
Kubernetes Reboot Daemon
Kubernetes Reboot Daemon

kured - Kubernetes Reboot Daemon Introduction Kubernetes & OS Compatibility Installation Configuration Reboot Sentinel File & Period Setting a schedul

Jan 3, 2023
cod is a completion daemon for bash/fish/zsh

Cod is a completion daemon for {bash,fish,zsh}. It detects usage of --help commands parses their output and generates auto-completions for your shell.

Dec 25, 2022
A modern IRC server (daemon/ircd) written in Go.
A modern IRC server (daemon/ircd) written in Go.

Oragono is a modern IRC server written in Go. Its core design principles are: Being simple to set up and use Combining the features of an ircd, a serv

Dec 31, 2022
a go daemon that syncs MongoDB to Elasticsearch in realtime. you know, for search.

monstache a go daemon that syncs mongodb to elasticsearch in realtime Version 6 This version of monstache is designed for MongoDB 3.6+ and Elasticsear

Dec 28, 2022
MySQL replication topology manager - agent (daemon)

orchestrator-agent MySQL topology agent (daemon) orchestrator-agent is a sub-project of orchestrator. It is a service that runs on MySQL hosts and com

Mar 8, 2022
A tiny cli command/daemon for syncing toggl time entries with Jira

toggl-sync A tiny cli command/daemon for syncing toggl time entries with Jira Installation Install the app via brew package manager. brew tap timemate

Nov 30, 2021