func run(action func() error) (errRun error) {
	defer func() {
		if e := recover(); e != nil {
			if err, ok := e.(error); ok {
				errRun = err
				return
			}
			errRun = errors.Errorf("UNKNOWN: %+v", e)
		}
	}()
	return action()
}
run calls the function, does captures panics
package supervisor
import (
	"fmt"
	"time"
	"github.com/pkg/errors"
)
type supervisorConf struct {
	intensity int
	period    time.Duration
	onError   func(error)
}
type Option func(supervisorConf) supervisorConf
func Intensity(intensity int) Option {
	return func(sc supervisorConf) supervisorConf {
		sc.intensity = intensity
		return sc
	}
}
func Period(period time.Duration) Option {
	return func(sc supervisorConf) supervisorConf {
		sc.period = period
		return sc
	}
}
func OnError(onError func(error)) Option {
	return func(sc supervisorConf) supervisorConf {
		sc.onError = onError
		return sc
	}
}
func Supervise(
	action func() error,
	options ...Option) {
	intensity, period, onError := validateAndRefine(options...)
	for intensity != 0 {
		if intensity > 0 {
			intensity--
		}
		if err := run(action); err != nil {
			if onError != nil {
				onError(err)
			}
			if intensity != 0 {
				time.Sleep(period)
			}
		} else {
			break
		}
	}
}