gappwrapp

command module
v0.0.0-...-99d8c9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gappwrapp

Lightweight process wrapper (for Linux/Mac) to execute commands with user-defined side-effects. gappwrapp = Go-Application-Wrapper.

Being developed with personal use-cases in mind, trying to improve my golang skills along the way. Just starting out - no code here yet :-)

Here's a list of things I'd like gappwrapp to do in the future (most are not implemented yet):

  • Capture status and duration of program, export them as prometheus metrics to a file
  • Timeout a command after a given time (alternative to the timeout command)
  • Pipe stderr and stdout to files (shorthands for > /var/log/myfile.log)
  • Prepend timestamps to stdout/stderr (similar to ts or gomon)
  • Pass along environment variables and signals to target command

This is how I think you'd use gappwrapp:

# Execute python scrip myscript.py using gappwrapp
$ gappwrapp --config etc/gappwrapp-myscript.toml -- python myscript.py --foo 123 --bar 456

$ cat gappwrapp-myscript.toml
[general]
timeout=120

[stdout]
timestamp=true
timestamp-format="%Y %M %d"
logfile=/var/log/mylogfile.log

[stderr]
timestamp=true
timestamp-format="%Y %M %d"
logfile=/var/log/mylogfile.log

[record]
duration=yes
status=yes

[export]
format=prometheus
metric_prefix="myscript_"
file=/opt/node_exporter/myfile.prom

Development

# Run during development
go run gapprwapp.go -- ls -la .
# IMPORTANT: When using 'go run', go will print the exit code of the program and not report the correct statuscode back to bash
# See here: https://stackoverflow.com/questions/26893774/how-to-disable-exit-status-1-when-executing-os-exit1

# Build binary
go build -o bin/darwin/gappwrapp gappwrapp.go

# Run binary
bin/darwin/gappwrapp

# Run tests
go test -v

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址