Git Product home page Git Product logo

swarm-service-restart's Introduction

swarm-service-restart

Some applications require periodic restarts to keep things running smoothly, but

Rather than using set of shell scripts or cron jobs, this tool allows you to attach a label to services (edu.wm.restartService.schedule) that contains a crontab like scheduling syntax.

The cron library used is a modified of robfig's cron.v2 library. The cron syntax is the same.

At this point I'd consider everything not quite alpha stability.

Requirements

The swarm-service-restart tool has to run on a manager node (or at least have access to a manager node's API, possibly using something like mikesir87 describes).

The binary can be run directly on the node, or can be run as its own service (recommended).

Example

A docker compose file might look something like

version: "3.7"

services:
  service-restarter:
    image: pcfens/swarm-service-restart
    deploy:
      placement:
        constraints:
          - node.role == manager
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        read_only: false

A service that will be restarted at 2am everyday would look something like

version: "3.7"

services:
  nginx:
    image: nginx
    deploy:
      labels:
        edu.wm.restartService.schedule: "0 2 * * *"

The files docker-compose.yaml and test-nginx.yaml are both used during development.

Future Plans

  • I'd like to build something like this for Kubernetes, possibly in the same tool.
  • As the code shows, I'm not all that familiar with Go, so there are numerous opportunities to clean things up.

swarm-service-restart's People

Contributors

pcfens avatar

Watchers

 avatar

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.