server

package
v0.0.0-...-b7e086b Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerFlagDisableVPN   = 1
	ServerFlagHotReloadWWW = 2 // Don't embed the 'www' directory into our binary, but load it from disk, and assume it's not immutable. This is for dev time on the 'www' source.
)
View Source
const BackgroundRecorderTickInterval = time.Second
View Source
const MaxVideoFileSize = 64 * 1024 * 1024

When doing long recordings, we split video files into chunks of approximately this size While developing, it's nice to have smaller video files (so we can see them earlier), but in production we'll probably want this to be chunkier (eg 1GB).

View Source
const MaxVideoFileSizeCheckInterval = 20 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtectedHandler

type ProtectedHandler func(w http.ResponseWriter, r *http.Request, params httprouter.Params, user *configdb.User)

type Server

type Server struct {
	Log              log.Log
	TempFiles        *util.TempFiles
	RingBufferSize   int
	MustRestart      bool           // Value of the 'restart' parameter to Shutdown()
	ShutdownStarted  chan bool      // This channel is closed when shutdown starts. So you can select() on it, to wait for shutdown.
	ShutdownComplete chan error     // Used by main() to report any shutdown errors
	OwnIP            net.IP         // If not nil, overrides the IP address used when scanning the LAN for cameras
	HotReloadWWW     bool           // Don't embed the 'www' directory into our binary, but load it from disk, and assume it's not immutable. This is for dev time on the 'www' source.
	StartupErrors    []StartupError // Critical errors encountered at startup. Note that these are errors that are resolvable by fixing the config through the App UI.

	// Public Subsystems
	LiveCameras *livecameras.LiveCameras
	// contains filtered or unexported fields
}

func NewServer

func NewServer(configDBFilename string, serverFlags int, explicitPrivateKey, kernelWGSecret string) (*Server, error)

Create a new server, load config, start cameras, and listen on HTTP

func (*Server) ApplyConfig

func (s *Server) ApplyConfig()

NEW: This replaces LoadConfigVariables This is called whenever system config changes

func (*Server) IsReady

func (s *Server) IsReady() error

DEPRECATED. Replaced by s.StartupErrors Returns nil if the system is ready to start listening to cameras Returns an error if some part of the system needs configuring The idea is that the web client will continue to show the configuration page until IsReady() returns true.

func (*Server) ListenForInterruptSignal

func (s *Server) ListenForInterruptSignal()

func (*Server) ListenHTTP

func (s *Server) ListenHTTP(port string) error

port example: ":8080"

func (*Server) LoadConfigVariables

func (s *Server) LoadConfigVariables() error

DEPRECATED. Replaced by ApplyConfig() Load state from 'variables'

func (*Server) RunBackgroundRecorderLoop

func (s *Server) RunBackgroundRecorderLoop()

func (*Server) SetPermanentStoragePath

func (s *Server) SetPermanentStoragePath(root string) error

func (*Server) SetRecentEventStoragePath

func (s *Server) SetRecentEventStoragePath(root string) error

func (*Server) SetTempFilePath

func (s *Server) SetTempFilePath(tempFilePath string) error

We don't want temp files to be on the videos dir, because the videos are likely to be stored on a USB flash drive, and this could cause the temp file to get written to disk, when we don't actually want that. We just want it as swap space... i.e. only written to disk if we run out of RAM.

func (*Server) SetupHTTP

func (s *Server) SetupHTTP() error

func (*Server) Shutdown

func (s *Server) Shutdown(restart bool)

func (*Server) StartVideoDB

func (s *Server) StartVideoDB() error

type StartupError

type StartupError struct {
	Code    StartupErrorCode `json:"code"`
	Message string           `json:"message"` // Possibly detailed message. We never want to throw an error message away, in case there is only one critical code path that elicits it.
}

type StartupErrorCode

type StartupErrorCode string

These are critical errors that prevent the system from functioning. The idea is that these errors appear on first run, and then you configure the system correctly, and once you've restarted the system and everything is good, then these errors drop to zero

const (
	// SYNC-STARTUP-ERROR-CODES
	StartupErrorArchivePath StartupErrorCode = "ARCHIVE_PATH" // Could be unconfigured or invalid. The front-end can figure that out by taking the user to the config page.
)

Directories

Path Synopsis
Package perfstats is a single place where we record the performance of various operations, so that it's easy to compare different solutions and the performance of different hardware.
Package perfstats is a single place where we record the performance of various operations, so that it's easy to compare different solutions and the performance of different hardware.

Jump to

Keyboard shortcuts

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