Git Product home page Git Product logo

isrunning-zig's Introduction

IsRunning

IsRunning is a very simple and lightweight Windows command-line utility to check if some processes are running or not.

It expects a list of process's names as argument and simply exits with code 0 if they were found, or 1 otherwise. No output or message is printed.

Usage:

IsRunning.exe PROCESS_1 [PROCESS_2] [PROCESS_N]

Examples

C:\> IsRunning.exe traefik.exe
C:\> echo %errorlevel%
0
C:\> IsRunning.exe traefik.exe node.exe
C:\> echo %errorlevel%
0
C:\> IsRunning.exe dead.exe
C:\> echo %errorlevel%
1

Motivation

Its main purpose is to serve as readiness probe for containers that spawn multiple processes.

For example, a Pod readiness probe to detect if traefik is running:

    readinessProbe:
      exec:
        command:
        - C:/IsRunning.exe
        - traefik.exe
      failureThreshold: 3
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 5

It's not advisable to run multiple processes on a single container, but for many reasons, it's not uncommon, especially for legacy applications in Microsoft Windows containers.

Why not use batch script?

I used to use a batch script combining tasklist and find together:

C:\> tasklist | find "traefik.exe"
C:\> echo %errorlevel%
0

It works, but it's not the most efficient solution, particularly when you call it every 5 seconds for hundreds of containers.

This utility saves a little bit of CPU and memory by removing the overhead of CMD interpreter and all the string processing between tasklist and find.

This utility is implemented in Zig, just because we needed a native, small, fast, and secure binary to perform such task.

Limitations

  • Windows only application

  • It is optimized for low memory consumption, and only works with ASCII processes names.

Please, feel free to open an issue or send a PR if you might improve this implementation in some sense.

isrunning-zig's People

Contributors

batiati avatar

Watchers

 avatar  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.