GithubHelp home page GithubHelp logo

kekahu's Introduction

KeKahu

Keep alive client for the Kahu service.

KeKahu is a client service for the Kahu API that manages hosts on our experimental test bed. KeKahu's primary role is to send a keep-alive heartbeat to Kahu at a routine interval. KeKahu also provides DDNS by using an public IP lookup and posting that IP address to Kahu. Finally KeKahu can be used to synchronize peers and access the Kahu API in a meaningful way.

Getting Started

As long as you have go version 1.10 or later installed you can get and install KeKahu as follows:

$ go get github.com/bbengfort/kekahu/...

This command will build and install the kekahu binary in $GOBIN. In order for the command to be used with systemd, however, you must install it into a system path such as /usr/local/bin. I recommend using a symlink to make sure that the latest binary is used as follows:

$ sudo ln -s $GOBIN/kekahu /usr/local/bin/kekahu

Now that KeKahu is installed you can see its commands and options:

$ kekahu --help

Most of KeKahu is configured through the environment, though command line options can be specified. A .env file can be used for local use or development. Ensure the following environmental variables are set:

  • $KEKAHU_API_KEY: the Kahu API key for this machine
  • $KEKAHU_URL (optional): url of the Kahu API
  • $KEKAHU_INTERVAL (optional): interval between heartbeats

Further configuration can be specified by a JSON, YAML, or TOML file in either /etc/kekahu.json or ~/.kekahu.json (with the appropriate extension). An example configuration is as follows:

{
  "interval": "20s",
  "api_key": "mysupersecretkey",
  "url": "https://kahu.io",
  "verbosity": 2,
  "peers_path": "peers.json",
  "api_timeout": "5s",
  "ping_timeout": "10s"
}

Note that KeKahu won't run without an API key.

Once the configuration is set, you can use the kekahu application. For example, to synchronize network peers:

$ kekahu sync

Systemd

Kekahu is configured to be managed by systemd on Linux systems. To get started create a file in /etc/systemd/system/kekahu.service as follows:

[Unit]
Description=KeKahu Service
Documentation=https://github.com/bbengfort/kekahu

[Service]
Type=simple
Environment=KEKAHU_API_KEY=mysupersecretkey
ExecStart=/usr/local/bin/kekahu run
Restart=on-abort

[Install]
WantedBy=multi-user.target

Now reload the services and enable the kekahu service:

$ sudo systemctl enable kekahu
$ sudo systemctl daemon-reload

The service can be managed with the start, stop, reload, and status commands as follows:

$ sudo systemctl start kekahu

You can check the status of the service to see if it started correctly, or use kekahu directly to check the status. In order to view the log files use the following command:

$ sudo journalctl -u kekahu

This should show everything written to stdout and stderr from the application.

Launchd

We can also run kekahu as a user-agent on OS X - meaning that it will only run while the user is logged in. Create a file called ~/Library/LaunchAgents/com.bengfort.kekahu.plist and add the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.bengfort.kekahu</string>

    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/kekahu</string>
        <string>start</string>
    </array>

    <key>RunAtLoad</key>
    <true/>

    <key>EnvironmentVariables</key>
    <dict>
        <key>KEKAHU_API_KEY</key>
        <string>mykey</string>
    </dict>

    <key>StandardOutPath</key>
    <string>/tmp/kekahu.log</string>

    <key>StandardErrorPath</key>
    <string>/tmp/kekahu.err</string>
</dict>
</plist>

Notes

kekahu's People

Contributors

bbengfort avatar

Watchers

 avatar  avatar

kekahu's Issues

Configuration from file

Right now the configuration is from environment variables, but this means that systemd scripts must include the API key, and this is not ideal. Instead, we should configure from a JSON file on disk, probably in /etc.

Cache neighbors

When running 10 pings, each request fetches the targets from the host again. While we want to ensure that we refresh the hosts every heartbeat we can cache the response for stuff in between (and between multiple threads).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.