15960d4269
* WIP creating admin node service - WIP changing the process pkg to accept multiple services - WIP looping over services passed to process - add netstate/service.go file and abstract it for service processing * implement goroutine to launch each process * goroutines working with multiple services * code review fixes * more code updates for review * Add pkg lock and mod files back in * code review updates * update process.Main with better concurrent error handling * Update error handling and pass ctx to StartService * Update error handling with channel implementation * Merge in upstream changes - Simplify error handling channels * updates * Updates per reviewable * fix test * Setup test exec * Scaffold test setup * process main test working * update admin process test * Test multiple processes done * Add error classes for testing, test main logger error * Updates to tests * Update how process.Main() handles configs * Complete merge * Update Gopkg and add Copyright * Fix cyclical import issue - Added .coverprofile to gitignore - Update admin main.go function call * remove unnecessary line * Updates * DRY up cmd/netstate package * update service function calls * updates * Trying no-ops in examples * rename netstate to pointerdb * trying to fix merge * dep ensure and run tests * remove flag.Parse * Update deps * Skip offending test in pkg/process, to be fixed later
38 lines
796 B
Go
38 lines
796 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"storj.io/storj/pkg/process"
|
|
"storj.io/storj/pkg/telemetry"
|
|
)
|
|
|
|
var (
|
|
addr = flag.String("addr", ":9000", "address to listen for metrics on")
|
|
)
|
|
|
|
func main() {
|
|
process.Must(process.Main(func() error { return nil }, process.ServiceFunc(run)))
|
|
}
|
|
|
|
func run(ctx context.Context, _ *cobra.Command, _ []string) error {
|
|
s, err := telemetry.Listen(*addr)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer s.Close()
|
|
fmt.Printf("listening on %s\n", s.Addr())
|
|
return s.Serve(ctx, telemetry.HandlerFunc(handle))
|
|
}
|
|
|
|
func handle(application, instance string, key []byte, val float64) {
|
|
fmt.Printf("%s %s %s %v\n", application, instance, string(key), val)
|
|
}
|