Coder Social home page Coder Social logo

mupuf / socket-activate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cherti/socket-activate

0.0 1.0 1.0 25 KB

Socket-activate any service that doesn't support systemd's socket activation

License: GNU General Public License v3.0

Go 100.00%

socket-activate's Introduction

socket-activate

This is a little tool to add systemd socket activation to services that do not support it yet. This way services don't have be started at system boot, but are instead started on demand on first interaction (and possibly never if never used).

socket-activate also supports deactivating services again after a certain time of inactivity to save system resources.

Usage

socket-activate can be used on its own, but it's most useful when used in conjunction with a systemd-socket-unit, obtaining systemd socket activation for arbitraty services (although currently only tcp-sockets are implemented, though).

socket-activate itself

Usage of ./socket-activate:
  -a string
        destination address (default "127.0.0.1:80")
  -m string
        mode, available: tcp (default "tcp")
  -t duration
        inactivity timeout after which to stop the unit again
  -u string
        corresponding unit (default "null.service")

Usage example: Grafana

Deploy a unit /etc/systemd/system/socket-activate-grafana.service (ensure you adjust the ExecStart according to the location of socket-activate):

[Unit]
Description=Socket activation proxy for grafana.service
Requires=socket-activate-grafana.socket

[Service]
ExecStart=/usr/bin/socket-activate -u grafana.service -a "127.0.0.1:3000" -t 15m
NonBlocking=true

and a corresponding unit /etc/systemd/system/socket-activate-grafana.socket:

[Unit]
Description=Socket for grafana.service

[Socket]
ListenStream=127.0.0.1:1234
NoDelay=true

[Install]
WantedBy=multi-user.target

You can now leave grafana.service disabled and stopped, it will automatically be activated once you access 127.0.0.1:1234 and proxy all requests to the Grafana instance behind. If -t is specified, Grafana will be stopped again after the specified amount of time of no interaction (in this case 15min).

How to get it

Arch

Install from AUR.

Build from source

Either

go get -u github.com/cherti/typemute

and find the binary in GOPATH/bin (defaults to ~/go/bin) or clone and

go get -u github.com/sqp/pulseaudio  # get the dependency
go build typemute.go  # and build locally

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.