kraken

package module
v0.0.0-...-6a6d86c Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2015 License: MIT Imports: 12 Imported by: 0

README

kraken is a on-demand http server: you can create new http servers at runtime through a RESTful API or one of the available clients. Those servers are meant to serve static files. It needs almost no configuration and can (will) save state across restarts.

Typical uses are sharing files quickly, on LAN or from a remote box. If you happen to often use python -m http.server, then this project should be of interest.

Install Build Status

Kraken is written in Go. The first step is to install Go on your system, if it isn't done yet.

Go is packaged for most linux distributions, but you can install it from a binary distribution or from source. To install the kraken programs, do go get github.com/vincent-petithory/kraken/... You can update an installation of kraken with go get -u github.com/vincent-petithory/kraken/...

Upon install, krakend and krakenctl are available.

There's also a PKGBUILD for Archlinux on AUR.

Quickstart

$ # Start the server
$ krakend
2014/08/22 16:50:17 [admin] Listening on 127.0.0.1:4214
2014/08/22 16:50:17 [admin] Available on http://127.0.0.1:4214

Here's a sample session, using the krakenctl client. It creates a http server and makes it serve $HOME/Pictures on http://localhost:4567/pics.

$ # Create a http server listening on port 4567, and bind it to localhost.
$ krakenctl add --bind=localhost 4567
server available on 127.0.0.1:4567
$ # Make it serve $HOME/Pictures mounted on /pics
$ krakenctl mount 4567 --target=/pics $HOME/Pictures
8f71ae0: /home/meow/Pictures -> /pics
$ # Print a status
$ krakenctl ls
127.0.0.1:4567
  * 8f71ae0: /home/vincent/Pictures -> /pics
$ # View contents in a browser
$ xdg-open http://localhost:4567/pics

Run:

krakenctl help

For help on all available commands.

Events

It is possible to monitor krakend activity by listening to events.

There are 3 kind of events:

  • server: a http server was created or deleted,
  • mount: a mount point has been created, deleted or updated on one http server,
  • fileserve: a file was served by a server on a mount point.

To listen to events, simply run

krakenctl events

This will listen to all events. To limit listening to only certain kind of events:

krakenctl events server mount

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMountTarget describes an invalid value for a mount target.
	ErrInvalidMountTarget = errors.New("invalid mount target value")
	// ErrInvalidMountSource describes an invalid value for a mount source.
	ErrInvalidMountSource = errors.New("invalid mount source value")
)

Functions

This section is empty.

Types

type MountMap

type MountMap struct {
	// contains filtered or unexported fields
}

func NewMountMap

func NewMountMap(fsf fileserver.Factory) *MountMap

func (*MountMap) DeleteTarget

func (mm *MountMap) DeleteTarget(mountTarget string) bool

Delete removes an existing mount target. It returns true if the mount target existed.

func (*MountMap) GetSource

func (mm *MountMap) GetSource(mountTarget string) string

GetSource retrieves the source for the given mount target. It returns "" if the mount target doesn't exist.

func (*MountMap) Put

func (mm *MountMap) Put(mountTarget string, mountSource string, fsType string, fsParams fileserver.Params) (bool, error)

Put registers a mount target for the given mount source. It returns true if the mount target already exists.

func (*MountMap) ServeHTTP

func (mm *MountMap) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MountMap) Targets

func (mm *MountMap) Targets() []string

type MountSourcePermError

type MountSourcePermError struct {
	// contains filtered or unexported fields
}

func (*MountSourcePermError) Error

func (e *MountSourcePermError) Error() string

type Server

type Server struct {
	MountMap       *MountMap
	HandlerWrapper func(http.Handler) http.Handler
	Addr           string
	Port           uint16
	Started        chan struct{}
	Running        bool
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, fsf fileserver.Factory) *Server

func (*Server) Close

func (s *Server) Close() error

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

type ServerPool

type ServerPool struct {
	Fsf fileserver.Factory
	// contains filtered or unexported fields
}

func NewServerPool

func NewServerPool(fsf fileserver.Factory) *ServerPool

func (*ServerPool) Add

func (sp *ServerPool) Add(addr string) (*Server, error)

func (*ServerPool) Get

func (sp *ServerPool) Get(port uint16) *Server

func (*ServerPool) Listen

func (sp *ServerPool) Listen()

func (*ServerPool) NServer

func (sp *ServerPool) NServer() int

func (*ServerPool) Remove

func (sp *ServerPool) Remove(port uint16) (bool, error)

func (*ServerPool) Servers

func (sp *ServerPool) Servers() []*Server

func (*ServerPool) StartSrv

func (sp *ServerPool) StartSrv(s *Server) bool

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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