daemon

package
v0.0.0-...-a6ec481 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2017 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package daemon simplifies the configuration of the aria2c daemon

Example
package main

import (
	"fmt"
	"time"

	"github.com/oliverpool/argo"
	"github.com/oliverpool/argo/daemon"
)

func main() {
	fmt.Println("Creating daemon configuration")
	aria2 := daemon.New()
	aria2.Option(daemon.Port("6801"), daemon.Secret("secretToken"), argo.Option{"max-concurrent-downloads": 1})

	fmt.Println("Launching daemon (in a goroutine)")
	cmd := aria2.Cmd()
	cmd.Start()

	fmt.Println("Wait until the adresse is ready to listen")
	for !daemon.IsRunningOn(":6801") {
		time.Sleep(time.Second)
	}

	fmt.Println("Killing daemon (not very nice... prefer to send a aria2.shutdown command)")
	cmd.Process.Kill()
	cmd.Wait()

	for daemon.IsRunningOn(":6801") {
		time.Sleep(time.Second)
	}

	fmt.Println("Bye")

}
Output:

Creating daemon configuration
Launching daemon (in a goroutine)
Wait until the adresse is ready to listen
Killing daemon (not very nice... prefer to send a aria2.shutdown command)
Bye

Index

Examples

Constants

This section is empty.

Variables

View Source
var EnableRPC = argo.Option{"enable-rpc": true}

EnableRPC enables JSON-RPC/XML-RPC server. It is strongly recommended to set secret authorization token using daemon.Secret option See also daemon.Port option

View Source
var ListenAll = argo.Option{"rpc-listen-all": true}

ListenAll listens incoming JSON-RPC/XML-RPC requests on all network interfaces. Default: listen only on local loopback interface (when option omitted).

Functions

func AppendArg

func AppendArg(args ...string) cmdOption

AppendArg creates an cmdOption to appends string to the command line.

aria2.CmdOption(daemon.AppendArg("some_raw_arg"))

func IsRunningOn

func IsRunningOn(address string) bool

IsRunningOn tests if the address is listening for TCP connections

func LogLevel

func LogLevel(level string) argo.Option

LogLevel to output to console. LEVEL is either debug, info, notice, warn or error. Default: notice (when option omitted)

func Port

func Port(port string) argo.Option

Port specifies a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 -65535. Default: 6800 (when option omitted)

func Secret

func Secret(secret string) argo.Option

Secret set RPC secret authorization token.

Types

type Aria2

type Aria2 struct {
	Name string
	// contains filtered or unexported fields
}

Aria2 stores the config to launch the daemon

func New

func New() Aria2

New creates a default daemon configuration

func (Aria2) Cmd

func (a Aria2) Cmd() *exec.Cmd

Cmd return the exec.Cmd to launch the aria2c daemon

func (*Aria2) CmdOption

func (a *Aria2) CmdOption(opts ...cmdOption)

CmdOption applies some cmdOptions on the command.

aria2.CmdOption(daemon.AppendArg("some_raw_arg"))

func (*Aria2) Option

func (a *Aria2) Option(opts ...argo.Option)

Option applies some options on the command.

aria2.Option(daemon.Port("6800"), daemon.ListenAll)

Jump to

Keyboard shortcuts

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