Multi-target build

Try to customize the MakeFile in order to be able to build an binary for
any target system.
This commit is contained in:
Bertrand Moreau 2020-08-18 17:18:45 +02:00
parent fa72c4cf35
commit 72c26f58c7
3 changed files with 184 additions and 174 deletions

2
.gitignore vendored
View File

@ -47,3 +47,5 @@ tags
# channel and emote list from twitch # channel and emote list from twitch
subscribers.json subscribers.json
/.settings/
/.project

View File

@ -5,10 +5,13 @@
# For info on installing extra versions, see this page: # For info on installing extra versions, see this page:
# https://golang.org/doc/install#extra_versions # https://golang.org/doc/install#extra_versions
# goosList = "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"
# goarchList = "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"
TAGS= TAGS=
# Windows needs the .exe extension. # Windows needs the .exe extension.
ifeq ($(OS),Windows_NT) ifeq ($(TARGET),windows)
EXT=.exe EXT=.exe
endif endif
@ -21,7 +24,7 @@ server: ServerMovieNight static/main.wasm
# Bulid used for deploying to my server. # Bulid used for deploying to my server.
ServerMovieNight: *.go common/*.go ServerMovieNight: *.go common/*.go
GOOS=linux GOARCH=386 go$(GO_VERSION) build -o MovieNight $(TAGS) GOOS=${TARGET} GOARCH=${ARCH} go$(GO_VERSION) build -o MovieNight $(TAGS)
setdev: setdev:
$(eval export TAGS=-tags "dev") $(eval export TAGS=-tags "dev")

349
readme.md
View File

@ -1,172 +1,177 @@
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc --> <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents** **Table of Contents**
- [MovieNight stream server](#movienight-stream-server) - [MovieNight stream server](#movienight-stream-server)
- [Build requirements](#build-requirements) - [Build requirements](#build-requirements)
- [Older Go Versions](#older-go-versions) - [Older Go Versions](#older-go-versions)
- [Compile and install](#compile-and-install) - [Compile and install](#compile-and-install)
- [Docker build](#docker-build) - [Docker build](#docker-build)
- [Building the Container](#building-the-container) - [Building the Container](#building-the-container)
- [Running the Container](#running-the-container) - [Running the Container](#running-the-container)
- [docker-compose](#docker-compose) - [docker-compose](#docker-compose)
- [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose) - [Notes for Running Using docker-compose](#notes-for-running-using-docker-compose)
- [Usage](#usage) - [Usage](#usage)
- [Configuration](#configuration) - [Configuration](#configuration)
<!-- markdown-toc end --> <!-- markdown-toc end -->
# MovieNight stream server # MovieNight stream server
[![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight) [![Build status](https://api.travis-ci.org/zorchenhimer/MovieNight.svg?branch=master)](https://travis-ci.org/zorchenhimer/MovieNight)
This is a single-instance streaming server with chat. Originally written to This is a single-instance streaming server with chat. Originally written to
replace Rabbit as the platform for watching movies with a group of people replace Rabbit as the platform for watching movies with a group of people
online. online.
## Build requirements ## Build requirements
- Go 1.13 or newer - Go 1.13 or newer
- GNU Make - GNU Make
### Older Go Versions ### Older Go Versions
You can install a newer version of Go alongside your OS's distribution by You can install a newer version of Go alongside your OS's distribution by
following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions) following the guide here: [https://golang.org/doc/install#extra_versions](https://golang.org/doc/install#extra_versions)
Once you have that setup add an enviromnent variable named `GO_VERSION` and Once you have that setup add an enviromnent variable named `GO_VERSION` and
set it to the version you installed (eg, `1.14.1`). The Makefile will now use set it to the version you installed (eg, `1.14.1`). The Makefile will now use
the newer version. the newer version.
### Compile and install ### Compile and install
You have to :
To just download and run: - download ;
- choose your `TARGET` "android darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris windows"
```bash ;
$ git clone https://github.com/zorchenhimer/MovieNight - choose your `ARCH` "386 amd64 amd64p32 arm arm64 ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32leppc s390 s390x sparc sparc64"
$ cd MovieNight ;
$ make - and run ;
$ ./MovieNight
``` ```bash
$ git clone https://github.com/zorchenhimer/MovieNight
### Docker build $ cd MovieNight
MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker. $ make TARGET=windows ARCH=386
$ ./MovieNight
#### Building the Container ```
Install Docker, clone the repository and build:
### Docker build
```shell MovieNight provides a Dockerfile and a docker-compose file to run MovieNight using Docker.
docker build -t movienight .
``` #### Building the Container
Install Docker, clone the repository and build:
#### Running the Container
Run the image once it's built: ```shell
docker build -t movienight .
```shell ```
docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight
``` #### Running the Container
Run the image once it's built:
Explanation:
- **-d** runs the container in the background. ```shell
- **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server. docker run -d -p 8089:8089 -p 1935:1935 [-v ./settings.json:/config/settings.json] movienight
- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server. ```
- **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL]
Explanation:
#### docker-compose - **-d** runs the container in the background.
docker-compose will automatically build the image, no need to build it manually. - **-p 8089:8089** maps the MovieNight web interface to port 8089 on the server.
- **-p 1935:1935** maps the RTMP port for OBS to port 1935 (default RTMP port) on the server.
Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run: - **-v ./settings.json:/config/settings.json** maps the file *settings.json* into the container. [OPTIONAL]
```shell #### docker-compose
docker-compose up -d docker-compose will automatically build the image, no need to build it manually.
```
Install Docker and docker-compose, clone the repository and change into the directory *./docker*. Then run:
This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host.
```shell
#### Notes for Running Using docker-compose docker-compose up -d
The container needs to be restarted to apply any changes you make to *settings.json*. ```
## Usage This docker-compose file will create a volume called *movienight-config* and automatically add the standard *settings.json* file to it. It also maps port 8089 and 1935 to the same ports of the host.
Now you can use OBS to push a stream to the server. Set the stream URL to #### Notes for Running Using docker-compose
The container needs to be restarted to apply any changes you make to *settings.json*.
```text
rtmp://your.domain.host/live ## Usage
```
Now you can use OBS to push a stream to the server. Set the stream URL to
and enter the stream key.
```text
Now you can view the stream at rtmp://your.domain.host/live
```
```text
http://your.domain.host:8089/ and enter the stream key.
```
Now you can view the stream at
There is a video only version at
```text
```text http://your.domain.host:8089/
http://your.domain.host:8089/video ```
```
There is a video only version at
and a chat only version at
```text
```text http://your.domain.host:8089/video
http://your.domain.host:8089/chat ```
```
and a chat only version at
The default listen port is `:8089`. It can be changed by providing a new port
at startup: ```text
http://your.domain.host:8089/chat
```text ```
Usage of .\MovieNight.exe:
-e bool The default listen port is `:8089`. It can be changed by providing a new port
Whether or not to download approved emotes on startup (default "false") at startup:
-k string
Stream key, to protect your stream (default: "") ```text
-l string Usage of .\MovieNight.exe:
host:port of the MovieNight (default ":8089") -e bool
-r string Whether or not to download approved emotes on startup (default "false")
host:port of the RTMP server (default ":1935") -k string
``` Stream key, to protect your stream (default: "")
-l string
## Configuration host:port of the MovieNight (default ":8089")
-r string
MovieNights configuration is controlled by `settings.json`: host:port of the RTMP server (default ":1935")
```
- `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves
admin privileges. This value is automatically regenerated unless ## Configuration
`RegenAdminPass` is false.
- `ApprovedEmotes`: list of Twitch users whose emotes can be imported into MovieNights configuration is controlled by `settings.json`:
MovieNight. Using `/addemotes <username>` in chat will add to this list.
- `Bans`: list of banned users. - `AdminPassword`: users can enter `/auth <value>` into chat to grant themselves
- `LetThemLurk`: if false, announces when a user enters and leaves chat. admin privileges. This value is automatically regenerated unless
- `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`. `RegenAdminPass` is false.
- `LogFile`: the path of the MovieNight logfile, relative to the executable. - `ApprovedEmotes`: list of Twitch users whose emotes can be imported into
- `LogLevel`: the log level, defaults to `debug`. MovieNight. Using `/addemotes <username>` in chat will add to this list.
- `MaxMessageCount`: the number of messages displayed in the chat window. - `Bans`: list of banned users.
- `NewPin`: if true, regenerates `RoomAccessPin` when the server starts. - `LetThemLurk`: if false, announces when a user enters and leaves chat.
- `PageTitle`: The base string used in the `<title>` element of the page. When - `ListenAddress`: the port that MovieNight listens on, formatted as `:8089`.
the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot` - `LogFile`: the path of the MovieNight logfile, relative to the executable.
- `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts. - `LogLevel`: the log level, defaults to `debug`.
- `RoomAccess`: the access policy of the chat room; this is managed by the - `MaxMessageCount`: the number of messages displayed in the chat window.
application and should not be edited manually. - `NewPin`: if true, regenerates `RoomAccessPin` when the server starts.
- `RoomAccessPin`: if set, serves as the password required to enter the chatroom. - `PageTitle`: The base string used in the `<title>` element of the page. When
- `SessionKey`: key used for storing session data (cookies etc.) the stream title is set with `/playing`, it is appended; e.g., `Movie Night | The Man Who Killed Hitler and Then the Bigfoot`
- `StreamKey`: the key that OBS will use to connect to MovieNight. - `RegenAdminPass`: if true, regenerates `AdminPassword` when the server starts.
- `StreamStats`: if true, prints statistics for the stream on server shutdown. - `RoomAccess`: the access policy of the chat room; this is managed by the
- `TitleLength`: the maximum allowed length for the stream title (set with `/playing`). application and should not be edited manually.
- `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes - `RoomAccessPin`: if set, serves as the password required to enter the chatroom.
- `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow). - `SessionKey`: key used for storing session data (cookies etc.)
- `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons - `StreamKey`: the key that OBS will use to connect to MovieNight.
or brackets; e.g., `:PogChamp:` - `StreamStats`: if true, prints statistics for the stream on server shutdown.
- `RateLimitChat`: the number of seconds between each message a non-privileged - `TitleLength`: the maximum allowed length for the stream title (set with `/playing`).
user can post in chat. - `TwitchClientID`: OAuth client ID for the Twitch API, used for fetching emotes
- `RateLimitNick`: the number of seconds before a user can change their nick again. - `TwitchClientSecret`: OAuth client secret for the Twitch API; [can be generated locally with curl](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-client-credentials-flow).
- `RakeLimitColor`: the number of seconds before a user can change their color again. - `WrappedEmotesOnly`: if true, requires that emote codes be wrapped in colons
- `RateLimitAuth`: the number of seconds between each allowed auth attempt or brackets; e.g., `:PogChamp:`
- `RateLimitDuplicate`: the numeber of seconds before a user can post a - `RateLimitChat`: the number of seconds between each message a non-privileged
duplicate message. user can post in chat.
- `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP - `RateLimitNick`: the number of seconds before a user can change their nick again.
header, to prevent caching responses. - `RakeLimitColor`: the number of seconds before a user can change their color again.
- `RateLimitAuth`: the number of seconds between each allowed auth attempt
## License - `RateLimitDuplicate`: the numeber of seconds before a user can post a
duplicate message.
`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license. - `NoCache`: if true, set `Cache-Control: no-cache, must-revalidate` in the HTTP
header, to prevent caching responses.
## License
`flv.js` is Licensed under the Apache 2.0 license. This project is licened under the MIT license.