garagepi

command module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2016 License: MIT Imports: 25 Imported by: 0

README

Garagepi

Build Status Coverage Status

A webserver written in golang to display output of Raspberry Pi camera module and trigger gpio.

A typical use would be to view the interior of a garage and trigger the garage door opener via gpio (and a relay).

Copyright © 2014-2016, Robert Dimsdale. Licensed under the MIT License.

Getting started

Requires jacksonliam's experimental mjpg-streamer.

Downloading

Obtain the most recent binary from the releases page.

Init scripts

Clone this repo, and from within the cloned directory copy the init scripts to /etc/init.d/ as follows:

sudo cp scripts/init-scripts/* /etc/init.d/

Set them to run automatically on boot:

sudo update-rc.d garagepi defaults
sudo update-rc.d garagestreamer defaults

The default location for the garagepi binary is /go/bin/garagepi. This is controlled by the GARAGE_PI_BINARY environment variable in scripts/init-scripts/garagepi. Edit the script and set this variable to the location of the downloaded binary.

Logging

By default logs are sent to the syslog with the tag garagepi as well as to the file /dev/null. The location of the additional file is controlled by the OUT_LOG environment variable in scripts/init-scripts/garagepi and scripts/init-scripts/garagestreamer. These can either be set to the same file or different files.

SSL

SSL requires a private key and a public certificate. The certificate should be the concatenated cert chain, e.g.:

-----BEGIN CERTIFICATE-----
(Your Primary SSL certificate: your_domain_name.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Intermediate certificate: DigiCertCA.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Root certificate: TrustedRoot.crt)
-----END CERTIFICATE-----

The trusted root CA is generally not required.

Performance

TLS

The Raspberry Pi supports TLS termination, but it is relatively slow. This causes a significant decrease in the framerate of the webcam (API and web calls are essentially unaffected).

If the TLS termination can happen upstream of the Pi, forwarding requests on in plain text to the Pi, the perfomance will be significantly improved.

Multiple clients

The mjpg-streamer supports relatively fast streaming to a single client, but multiple clients significantly decrease the framerate of the webcam.

Multiple Pis

If using Raspberry Pi 2, there is no performance gained by using multiple Raspberry Pis.

If using Raspberry Pi 1, performance can be improved by using multiple Pis - one for the mjpg streamer (with the camera attached) and one for the Go webserver (with the gpio attached). The responsiveness of the Go webserver is significantly improved and the framerate of the streamer improved slightly. Stability appears much better (the webserver/streamer crash more frequently when co-located on the same Pi).

The gpio utility is lightweight and so it may be installed on both, but it is only required to be installed on the Pi directly attached to the relay. The streamer utility, however, requires much more resouce and therefore should only be installed on the Pi with the camera attached.

On the Pi with the camera, copy only the garage streamer start script:

sudo cp scripts/init-scripts/garagestreamer /etc/init.d/
sudo update-rc.d garagestreamer defaults

On the Pi with the Go webserver and gpio, copy only the garagepi start script:

sudo cp scripts/init-scripts/garagepi /etc/init.d/
sudo update-rc.d garagepi defaults

By default, the garagepi webserver assumes the webcam is available on localhost:8080. This is controlled by the the environment variables $WEBCAM_HOST and $WEBCAM_PORT in scripts/init-scripts/garagepi.

Development

Requires Golang 1.4 or higher.

Go dependencies

Dependencies are managed using godep. Install it as follows:

go get -u github.com/tools/godep

From within the directory of this cloned repo, fetch the golang dependencies:

godep restore

To regenerate the embedded assets, install the esc tool:

go get github.com/mjibson/esc

and then run the script which creates them:

./scripts/create-embedded-assets
Running the tests

The tests require the ginkgo binary and phantomJS.

Install ginkgo via go get:

go get github.com/onsi/github.com/ginkgo/ginkgo

Install phantomJS e.g. for OSX:

brew install phantomjs

Execute the unit and integration tests with:

./scripts/unit-test
./scripts/integration-tests

Project administration

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/golang/protobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/golang/protobuf/proto/proto3_proto
Package proto3_proto is a generated protocol buffer package.
Package proto3_proto is a generated protocol buffer package.
_workspace/src/github.com/gorilla/context
Package context stores values shared during a request lifetime.
Package context stores values shared during a request lifetime.
_workspace/src/github.com/gorilla/mux
Package gorilla/mux implements a request router and dispatcher.
Package gorilla/mux implements a request router and dispatcher.
_workspace/src/github.com/gorilla/securecookie
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
Package gorilla/securecookie encodes and decodes authenticated and optionally encrypted cookie values.
_workspace/src/github.com/onsi/ginkgo
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
_workspace/src/github.com/onsi/ginkgo/config
Ginkgo accepts a number of configuration options.
Ginkgo accepts a number of configuration options.
_workspace/src/github.com/onsi/ginkgo/ginkgo
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use.
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) You can also learn more by running: ginkgo help Here are some of the more commonly used commands: To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To pass arguments/flags to your tests: ginkgo <flags> <packages> -- <pass-throughs> To run tests in parallel ginkgo -p this will automatically detect the optimal number of nodes to use.
_workspace/src/github.com/onsi/ginkgo/internal/remote
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output coherently as tests complete.
_workspace/src/github.com/onsi/ginkgo/reporters
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
_workspace/src/github.com/onsi/gomega
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
_workspace/src/github.com/onsi/gomega/format
Gomega's format package pretty-prints objects.
Gomega's format package pretty-prints objects.
_workspace/src/github.com/onsi/gomega/gbytes
Package gbytes provides a buffer that supports incrementally detecting input.
Package gbytes provides a buffer that supports incrementally detecting input.
_workspace/src/github.com/onsi/gomega/gexec
Package gexec provides support for testing external processes.
Package gexec provides support for testing external processes.
_workspace/src/github.com/onsi/gomega/ghttp
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers.
Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports registering multiple handlers.
_workspace/src/github.com/onsi/gomega/ghttp/protobuf
Package protobuf is a generated protocol buffer package.
Package protobuf is a generated protocol buffer package.
_workspace/src/github.com/onsi/gomega/matchers
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
_workspace/src/github.com/sclevine/agouti
Package agouti is a universal WebDriver client for Go.
Package agouti is a universal WebDriver client for Go.
_workspace/src/github.com/sclevine/agouti/api
Package api provides a generic, low-level WebDriver API client for Go.
Package api provides a generic, low-level WebDriver API client for Go.
_workspace/src/github.com/sclevine/agouti/matchers
Package matchers provides a set of Gomega-compatible matchers for use with the agouti package.
Package matchers provides a set of Gomega-compatible matchers for use with the agouti package.
_workspace/src/github.com/tedsuo/ifrit
A process model for go.
A process model for go.
_workspace/src/github.com/tedsuo/ifrit/fake_runner
fake_runner contains test fixtures.
fake_runner contains test fixtures.
_workspace/src/github.com/tedsuo/ifrit/ginkgomon
Ginkgomon provides ginkgo test helpers.
Ginkgomon provides ginkgo test helpers.
_workspace/src/github.com/tedsuo/ifrit/grouper
Grouper implements process orcestration.
Grouper implements process orcestration.
_workspace/src/github.com/tedsuo/ifrit/restart
The restart package implements common restart strategies for ifrit processes.
The restart package implements common restart strategies for ifrit processes.
api
door/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
light/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
This file was generated by counterfeiter
This file was generated by counterfeiter
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
fakes
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
os
fakes
This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter
web
homepage/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
login/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
webcam/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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