"io/ioutil"
	flag "launchpad.net/gnuflag"
	"log"
	"net/http"
	"os"
	"os/signal"
	"strconv"
	"strings"
	"syscall"
	"time"
)

var VERSION string
var MINVERSION string

var helpFlag = flag.Bool("help", false, "Show this screen")
var tracksFlag = flag.String("tracks", "", "Comma separated list of track_ids eg. 123,231,122")
var fileFlag = flag.String("file", "", "A file of line separated track_ids")
var playedTracksCount = map[string]int{}
var tracks []TrackInfo

var HTTP_ERR_RETRY = time.Duration(10)
var HTTP_GET_ERROR = "HTTP GET for %s failed.\nWaiting 10s and trying again.."
var HTTP_ETAG_GET_ERROR = "ETAG cached HTTP GET for %s failed.\nWaiting 10s and trying again.."

func output_welcome() {
	fmt.Printf("\033]0;unearthd-bumpr v%s\007", VERSION)
	fmt.Println()
	fmt.Printf("Unearthd Track Bumpr - v%s\n", VERSION)
	fmt.Println("Created by NUR (Never Underestimate Reason)")
	fmt.Println()
Exemple #2
0
	"path/filepath"
	"strings"
	"time"

	"github.com/juju/juju/agent"
	"github.com/juju/juju/mongo"
	"github.com/juju/juju/state"
	"github.com/juju/replicaset"
	"github.com/kr/pretty"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
	"gopkg.in/mgo.v2/txn"
	flag "launchpad.net/gnuflag"
)

var nflag = flag.Bool("n", false, "print ops but don't actually change anything")

func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: juju-stateservers machine-id...\n")
		flag.PrintDefaults()
		os.Exit(2)
	}
	flag.Parse(true)
	if err := setStateServers(flag.Args()); err != nil {
		fmt.Fprintf(os.Stderr, "cannot set state servers: %v\n", err)
		os.Exit(1)
	}
}

type serverInfo struct {
	"strings"
	"unicode"
)

var VERSION string
var MINVERSION string

var STD_OUT = bufio.NewWriter(colorable.NewColorableStdout())
var STD_ERR = bufio.NewWriter(colorable.NewColorableStderr())
var STD_IN = bufio.NewReader(os.Stdin)

var DATABASE_FILENAME = "cover_urls.boltdb"
var DATABASE_BUCKET = []byte("CoverImages")
var DEFAULT_OUTPUT_FILENAME = "output.jpg"

var aboutFlag = flag.Bool("about", false, "About the application")
var trackListFlag = flag.String("tracklist", "", "A file containing a tracklist")
var outputFileFlag = flag.String("output", "", "The file to output the generate cover to")
var overlayFlag = flag.String("overlay", "", "A file to overlay on top of the generated image")

func main() {

	flag.Parse(true)
	showWelcomeMessage()
	if *aboutFlag == true {
		showAboutMessage()
		os.Exit(0)
	}

	var tracklist []Track
	tracklistFileName := ""
Exemple #4
0
func main() {
	foreground := flag.Bool("f", false, "Run application foreground, don't daemonize")
	config_path := flag.String("config", "config.json", "Configuration file path")
	pid_path := flag.String("pid", "/var/run/ng_backend.pid", "PID file path")
	flag.Parse(false)
	init_config(*config_path)
	d_config := get_daemon_config()
	state_config := get_state_config()
	metric_config := get_metric_config()
	graph_config := get_graph_config()

	if !*foreground {
		cntxt := &daemon.Context{
			PidFileName: *pid_path,
			PidFilePerm: 0644,
			LogFileName: d_config.GetString("log_file"),
			LogFilePerm: 0640,
			WorkDir:     "./",
			Umask:       027,
			Args:        []string{},
		}

		d, err := cntxt.Reborn()
		if err != nil {
			log.Fatalln(err)
		}
		if d != nil {
			return
		}
		defer cntxt.Release()
	}

	log.Println("Starting NetAssist NetGraphz2...")

	log.Printf("Create memory metric storage with capacity of %d records per metric\n", metric_config.GetInt("mem_storage.capacity"))

	metric_store := metric.NewMemoryStorage(metric_config.GetInt("mem_storage.capacity"))
	status_srv := state.NewStatusService(state.NewMemoryStateCache(), time.Duration(state_config.GetInt("cache.ttl"))*time.Millisecond)
	graph_store := graph.NewNeoGraphStorage(graph_config.GetString("url"))

	icinga_config := state.IcingaLiveStatusConfig{}
	icinga_config.HostName = state_config.GetString("icinga.host")
	icinga_config.Port = uint16(state_config.GetInt("icinga.port"))
	icinga_config.UseUnixSocket = state_config.GetBool("icinga.use_unix_socket")
	icinga_config.UnixSocket = state_config.GetString("icinga.unix_socket")
	icinga_config.TimeoutEnable = state_config.GetBool("icinga.timeout_enabled")
	icinga_config.Timeout = time.Duration(state_config.GetInt("icinga.timeout")) * time.Millisecond

	icinga_source := state.NewIcingaLiveStateSource(icinga_config)
	status_srv.AddSource(icinga_source)

	lis, err := net.Listen("tcp", net.JoinHostPort(d_config.GetString("rpc_host"), fmt.Sprintf("%d", d_config.GetInt("rpc_port"))))
	if err != nil {
		log.Printf("failed to listen: %v", err)
	}
	var opts []grpc.ServerOption
	grpcServer := grpc.NewServer(opts...)
	rpc.RegisterBackendServer(grpcServer, rpc_server.NewRPCServer(graph_store, status_srv, metric_store))

	go func() {
		log.Printf("gRPC server starting on %s:%d\n", d_config.GetString("rpc_host"), d_config.GetInt("rpc_port"))
		err := grpcServer.Serve(lis)
		if err != nil {
			log.Fatalf("Error during listening: %v\n", err)
		}
	}()

	log.Printf("Starting collectd listener on %s:%d\n", metric_config.GetString("collectd.host"), metric_config.GetInt("collectd.port"))

	source := metric.NewCollectdMetricSource(metric_config.GetString("collectd.host"), uint16(metric_config.GetInt("collectd.port")), metric_config.GetBool("collectd.filter_enable"), metric_config.GetStringSlice("collectd.filter_types"))
	source.AddStorage(metric_store)
	log.Println("Collecting collectd metrics")
	source.Collect()
}
Exemple #5
0
	"time"
	"unicode/utf8"

	"github.com/juju/errors"
	"github.com/juju/juju/cmd/envcmd"
	"github.com/juju/juju/environs"
	"github.com/juju/juju/environs/configstore"
	"github.com/juju/juju/juju"
	"github.com/juju/juju/juju/osenv"
	"github.com/juju/juju/state/api"
	"github.com/juju/names"
)

var (
	envName = flag.String("e", "", "environment name")
	verbose = flag.Bool("v", false, "verbose")
	timeout = flag.Duration("timeout", 5*time.Minute, "maximum timeout")
)

func main() {
	flag.Parse(true)
	if err := main0(); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
}

var startTime = time.Now()

func main0() error {
	if err := juju.InitJujuHome(); err != nil {
Exemple #6
0
package main

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/globocom/tsuru/cmd"
	"github.com/globocom/tsuru/cmd/tsuru"
	"io/ioutil"
	"launchpad.net/gnuflag"
	"net/http"
)

var AssumeYes = gnuflag.Bool("assume-yes", false, "Don't ask for confirmation on operations.")
var NumUnits = gnuflag.Uint("units", 1, "How many units should be created with the app.")

type AppCreate struct{}

func (c *AppCreate) Run(context *cmd.Context, client cmd.Doer) error {
	if *NumUnits == 0 {
		return errors.New("Cannot create app with zero units.")
	}
	appName := context.Args[0]
	framework := context.Args[1]
	b := bytes.NewBufferString(fmt.Sprintf(`{"name":"%s","framework":"%s","units":%d}`, appName, framework, *NumUnits))
	request, err := http.NewRequest("POST", cmd.GetUrl("/apps"), b)
	request.Header.Set("Content-Type", "application/json")
	if err != nil {
		return err
Exemple #7
0
var OAUTH_CLIENT_ID string
var OAUTH_CLIENT_SECRET string

var OAUTH_REDIRECT_URI = "http://www.rhythmandpoetry.net/mixcloud_code.php"
var API_URL = "https://api.mixcloud.com/upload/?access_token="
var ACCESS_TOKEN_URL = "https://www.mixcloud.com/oauth/access_token?client_id=" + OAUTH_CLIENT_ID + "&redirect_uri=" + OAUTH_REDIRECT_URI + "&client_secret=" + OAUTH_CLIENT_SECRET + "&code=%s"
var API_ME_URL = "https://api.mixcloud.com/me?access_token="
var CONFIG_FILE = "config.json"
var CONFIG_FILE_PATH = ""

var TRACKLIST_OUTPUT_FORMAT = "%d. %s-%s\n"

var CURRENT_USER mixcloud.User = mixcloud.User{}
var configuration = Configuration{}

var aboutFlag = flag.Bool("about", false, "About the application")
var configFlag = flag.Bool("config", false, "Configure the application")
var fileFlag = flag.String("file", "", "The mp3 file to upload to mixcloud")
var coverFlag = flag.String("cover", "", "The image file to upload to mixcloud as the cover")
var trackListFlag = flag.String("tracklist", "", "A file containing a VirtualDJ Tracklist for the cloudcast")

var STD_OUT = bufio.NewWriter(colorable.NewColorableStdout())
var STD_ERR = bufio.NewWriter(colorable.NewColorableStderr())
var STD_IN = bufio.NewReader(os.Stdin)

type Configuration struct {
	ACCESS_TOKEN string
	DEFAULT_TAGS string
}

func showWelcomeMessage() {