Coder Social home page Coder Social logo

ydudin / garagepi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robdimsdale/garagepi

0.0 2.0 0.0 5.6 MB

Golang webserver to display output of Raspberry Pi camera module and trigger gpio.

License: MIT License

Go 91.52% Shell 7.74% CSS 0.08% JavaScript 0.66%

garagepi's Introduction

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

garagepi's People

Contributors

robdimsdale avatar

Watchers

James Cloos avatar Yuliyan Dudin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.