Commit Graph

699 Commits

Author SHA1 Message Date
Scott Lamb b41a6c43da shutdown better
After a frustrating search for a suitable channel to use for shutdown
(tokio::sync::Receiver and
futures::future::Shared<tokio::sync::oneshot::Receiver> didn't look
quite right) in which I rethought my life decisions, I finally just made
my own (server/base/shutdown.rs). We can easily poll it or wait for it
in async or sync contexts. Most importantly, it's convenient; not that
it really matters here, but it's also efficient.

We now do a slightly better job of propagating a "graceful" shutdown
signal, and this channel will give us tools to improve it over time.

* Shut down even when writer or syncer operations are stuck. Fixes #117
* Not done yet: streamers should instantly shut down without waiting for
  a connection attempt or frame or something. I'll probably
  implement that when removing --rtsp-library=ffmpeg. The code should be
  cleaner then.
* Not done yet: fix a couple places that sleep for up to a second when
  they could shut down immediately. I just need to do the plumbing for
  mock clocks to work.

I also implemented an immediate shutdown mode, activated by a second
signal. I think this will mitigate the streamer wait situation.
2021-09-23 16:33:29 -07:00
Scott Lamb 66f76079c0 improve error when db and dir meta don't match
I saw this recently while working on new-schema. It was probably due
to some manual upgrade or downgrade I did rather than an actual bug.
Improve debuggability a little nonetheless.
2021-09-22 12:39:02 -07:00
Scott Lamb 901ba121a2 include suspended time in monotonic timestamps 2021-09-16 18:21:27 -07:00
John Poole 156d3dde9d Update build.md
See Issue #163
2021-09-16 16:18:56 -07:00
John Poole de7c93bdfa Update time.md
flagged "ppm" to indicate it is defined in the glossary
2021-09-13 17:00:43 -07:00
John Poole a6bcb82341 Update glossary.md
Defining ppm and giving example of how it is relevent
2021-09-13 17:00:20 -07:00
Scott Lamb 92f594ef58 handle stale RTSP sessions
* upgrade to Retina 0.3.1 which automatically tears down sessions
* wait out stale sessions before reconnecting
* wait for teardown to complete before shutting down

This adds some pressure on #117: it will keep waiting for the stale
session to expire even if the user has requested shutdown. I'll try
to address that next.
2021-09-09 22:10:45 -07:00
Scott Lamb 981a91c425 add changelog entry for #157 2021-08-31 16:44:53 -07:00
Scott Lamb 7e5bc42646 improve init segment fetch error msg
Fixes #146, in combination with earlier commit 4892ed7.
2021-08-31 16:41:43 -07:00
Scott Lamb d2c7b62771 fix #157: problem with live multi-camera selection
When you select the first camera in the drop-down on a grid square
that isn't the top left, then select a camera in the top-left, it
behaves strangely.

The root cause is that I had a dumb mistake in how I assigned React
keys. I used the camera index when a camera is selected, and the
inverse of the selected index when one is. But 0 == -0!
2021-08-31 16:20:24 -07:00
dependabot[bot] 0a38044b02 Bump tar from 6.1.0 to 6.1.11 in /ui
Bumps [tar](https://github.com/npm/node-tar) from 6.1.0 to 6.1.11.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v6.1.0...v6.1.11)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 15:17:30 -07:00
Scott Lamb d53450dd3b bump versions of blake3, nom, tokio-tungstenite 2021-08-31 13:05:10 -07:00
Scott Lamb 806d7b6d20 cargo update 2021-08-31 12:59:39 -07:00
Scott Lamb 30d5807dd3 include ids in api responses for debugging 2021-08-31 12:05:03 -07:00
Scott Lamb 3de605be6c improve some log msgs' readability 2021-08-31 08:59:33 -07:00
Scott Lamb 78bafb01f6 support udp with retina or ffmpeg 2021-08-31 08:11:18 -07:00
Scott Lamb 7ed02bd112 improve install guide wording (see #151) 2021-08-26 09:49:43 -07:00
Scott Lamb 71e5248c6b fix tests broken with 95dec97 2021-08-23 15:58:12 -07:00
Scott Lamb 95dec9791c config: validate more in cameras dialog box
Fixes #152

This won't win any awards for best UI or cleanest UI code, but it's an
improvement. Long-term I want the web config UI instead.
2021-08-23 15:55:47 -07:00
Scott Lamb 30cea5cfcb several documentation improvements
*   prefix docker/nvr commands with sudo (fixes #142).
    I was just going to link to the docker documentation on setting
    up non-root access, but that's kind of a personal preference.
    I included a `<details>` about it instead and made all the commands
    work with sudo.

*   take better advantage of github markdown's code block syntax
    highlighting. Use "console" for shell session stuff, put the
    "nvr" wrapper script in its own block with "bash".

*   add some comments to nvr wrapper script where people need to
    make changes and/or will be confused.

*   add a `<details>` that talks about shutting down and restarting
    the session around `nvr config` (see #151). Still not user-friendly
    but at least it's better documented now.
2021-08-23 12:44:48 -07:00
Scott Lamb a16bda8fb1 use retina v0.2.0 2021-08-20 16:52:58 -07:00
Scott Lamb f904ba7a79 allow specifying username with empty password
Reolink cameras ship with username "admin", password "", so this is
necessary to use them fresh out of the box.
2021-08-20 09:45:58 -07:00
Scott Lamb 826b81a95c further refine UI install cmd (#150)
* add the command to create `/usr/local/lib/moonfire-nvr`, necessary
  the first time
* have the files owned by root and use world-readable permissions, even
  if the building user has a restrictive umask set
2021-08-19 21:54:58 -07:00
Scott Lamb 7518b4c865 correctly describe installation in build guide
There were several incorrect/out-of-date paths here, and it didn't
have example commands to install the server or UI.

Fixes #150
2021-08-19 21:43:16 -07:00
Scott Lamb 4892ed77d1 update http-serve to fix erroneous 304
This mostly affects .mp4 init segments (#146), which currently set the
Last-Modified: date to the epoch. It could also affect other resources
(static files, other .mp4 changes) but only if the clock has gone
backwards.
2021-08-19 21:30:47 -07:00
Scott Lamb 5c3c61838f improve Reolink interoperability with new Retina
Attempt at #114 and #144. Let's see how much it helps.
2021-08-19 15:06:20 -07:00
Scott Lamb 6270cc0ee4 adjust minimum SQLite version
"without rowid" was introduced in 3.8.2, not 3.14.0. The latter
was just "without rowid" virtual tables, a more obscure feature.
2021-08-19 10:59:38 -07:00
Scott Lamb a574b51e26 caution against distro Rust pkgs (#109) 2021-08-19 10:37:02 -07:00
Scott Lamb 4e77a26410 document and check minimum SQLite version
Fixes #147
2021-08-19 10:08:53 -07:00
Scott Lamb dd4a901adb bump etag format version when headers change
I forgot to do this in 27395ec resulting in #146. Bump the version now,
and update the digest used in the tests so they will remind me to
bump the version any time the headers change.
2021-08-19 09:51:09 -07:00
Scott Lamb 4204d84bde
disable proxy buffering in nginx
Buffering to local disk is unnecessary and wasteful.
Moonfire connections are cheap.
2021-08-13 15:28:31 -07:00
Scott Lamb 711071f003 prepare version 0.6.5 2021-08-13 12:08:19 -07:00
Scott Lamb b8b5038f71 better error msg on live view when misconfigured
Improves (but doesn't fix) #119 and #120.
2021-08-13 12:02:42 -07:00
Scott Lamb 42cf77f0d6 upgrade to retina v0.1.0 2021-08-13 11:48:58 -07:00
Scott Lamb 27098b5fdc fix filesystem row alignment in dir config 2021-08-13 08:56:12 -07:00
Scott Lamb b388aab250 better error message for live view on iOS (#121) 2021-08-13 08:50:06 -07:00
Scott Lamb 900cb927f3 cargo fmt
(I keep forgetting that I've enabled cargo fmt checking on this repo.)
2021-08-12 13:42:12 -07:00
Scott Lamb 27395ecd4e UI: improve aspect ratio handling
As written in the changelog: Live streams formerly worked around a
Firefox pixel aspect ratio bug by forcing all videos to 16:9, which
dramatically distorted 9:16 camera views. Playback didn't, so anamorphic
videos looked correct on Chrome but slightly stretched on Firefox. Now
both live streams and playback are fully correct on all browsers.
2021-08-12 13:33:19 -07:00
Scott Lamb 115b081dcd update arm docker build notes 2021-08-12 09:36:13 -07:00
Scott Lamb f512d5cacb typo: don't run on node 18 2021-08-11 23:56:29 -07:00
Scott Lamb 164c8c5b21 clarify support for node 12 and 14
* run node 12, 14, and 16 (next to be supported) on CI. This will catch
  node version-specific problems like that solved in dad9bdc.
* mention 12 and 14 in build instructions and link to instructions for
  installing that version.
* follow this in Dockerfile, installing version 14. This addresses
  a "Cannot find module 'worker_threads'" error introduced in
  39a63e0, which (inadvisedly) upgraded gzipper 4->5 in addition to
  the material-ui upgrade.
* use utf-8 encoding rather than ascii in live part parser. Those
  builds apparently don't support ascii. iThey must use "small-icu" or
  have ICU disabled, as described here:
  https://nodejs.org/api/util.html#util_encodings_supported_when_node_js_is_built_with_the_small_icu_option
2021-08-11 23:45:17 -07:00
Scott Lamb 6426745c8c link to material-ui issue about date picker sizing 2021-08-11 15:06:03 -07:00
Scott Lamb f4c70803d3 add warning about docker builds not working on arm
see #141
2021-08-11 14:38:41 -07:00
Scott Lamb 889deac5be explicitly cd into dir in build instructions
as suggested in #141
2021-08-11 13:52:53 -07:00
Scott Lamb dad9bdc20f fix test error with node 14
This worked fine on my workstation with node 12. But on CI or my laptop
with node 14, it failed. Apparently there @testing-library/user-events
expects a peer @testing-library/dom dependency. At least copying the
"npm install --save-dev @testing-library/user-event @testing-library/dom" command
from the top of https://testing-library.com/docs/ecosystem-user-event/
made it work again on my laptop; fingers crossed about CI.
2021-08-10 13:07:13 -07:00
Scott Lamb 39a63e03ae upgrade material-ui to latest beta
This is a surprisingly complex upgrade. Some relevant changes from
[their CHANGELOG](https://github.com/mui-org/material-ui/blob/v5.0.0-beta.3/CHANGELOG.md):

* @material-ui/core/styles no longer re-exports some stuff from
  @material-ui/styles
* there's no more defaultTheme, so tests need to provide one
* select's onChange has a new type; match that. I haven't actually
  tried that the string form (apparently from autofill) works correctly.
* checkboxes no longer default to the secondary color; explicitly
  request this in some places.
* checkbox no longer has a checked argument; use event.target.checked
  instead.
* date pickers have switched to the new style system, so I had to
  redo how I was overridding their spacing for desktop.
* LoadingButton now has a loading property, not pending
* createMuiTheme is no createTheme
2021-08-10 12:43:10 -07:00
Scott Lamb c55032dfcd don't panic on bind failure
Fixes #136

Before:

```
E20210803 09:00:31.161 main moonfire_nvr] panic at '/Users/slamb/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.10/src/server/server.rs:68:17': error binding to 0.0.0.0:80: error creating server listener: Address already in use (os error 48)

(set environment variable RUST_BACKTRACE=1 to see backtraces)
...potentially unrelated log msgs from other threads before exiting...
```

After:

```
E20210803 09:06:02.633 main moonfire_nvr] Exiting due to error: unable to bind --http-addr=0.0.0.0:80
caused by: error creating server listener: Address already in use (os error 48)

(set environment variable RUST_BACKTRACE=1 to see backtraces)
```
2021-08-03 09:09:11 -05:00
Scott Lamb dcfe792032 display String panic msgs as well as &str ones
For #136. I'm also going to make this particular case no longer panic,
but there will surely be other affected panics.

Before:

```
E20210803 08:58:31.606 main moonfire_nvr] panic at '/Users/slamb/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.10/src/server/server.rs:68:17'
```

After:

```
E20210803 08:59:51.319 main moonfire_nvr] panic at '/Users/slamb/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.10/src/server/server.rs:68:17': error binding to 0.0.0.0:80: error creating server listener: Address already in use (os error 48)
```
2021-08-03 09:00:37 -05:00
Scott Lamb 84ce447fab
use journald log driver in docker wrapper script
As mentioned in https://lwn.net/Articles/676831/, Docker's default loses the logs every time a container is destroyed. Also, https://docs.docker.com/config/containers/logging/configure/ says that the default never rotates the logfiles.
2021-07-16 09:23:45 -07:00
Scott Lamb 3ce9366b0c links to system setup wiki page 2021-07-13 16:08:50 -07:00