Skip to content

Commit 6dfc0ec

Browse files
committed
re-organize for luarocks
1 parent ba15f70 commit 6dfc0ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1275
-1113
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/config.lua
2+
/etc/config.yaml
23
/lua_modules
34
/static/favicon.ico
45
/.lua-version
56
*.swp
67
/local/
8+
/share/multistreamer/html/local

LICENSE-lua-resty-redis

Lines changed: 0 additions & 13 deletions
This file was deleted.

LICENSE-lua-resty-websocket

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 68 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,33 @@ Here's some guides on installing/using:
5858

5959
## Table of Contents
6060

61-
* [Requirements](#requirements)
62-
* [Installation](#installation)
63-
+ [Install with Docker](#install-with-docker)
64-
+ [Install OpenResty with `setup-openresty`](#install-openresty-with-setup-openresty)
65-
+ [Alternative: Install OpenResty with RTMP Manually](#alternative-install-openresty-with-rtmp-manually)
66-
+ [Setup database and user in Postgres](#setup-database-and-user-in-postgres)
67-
+ [Setup Redis](#setup-redis)
68-
+ [Setup Sockexec](#setup-sockexec)
69-
+ [Setup Authentication Server](#setup-authentication-server)
70-
+ [Clone and setup](#clone-and-setup)
71-
+ [Install Lua modules](#install-lua-modules)
72-
+ [Initialize the database](#initialize-the-database)
73-
* [Usage](#usage)
74-
+ [Start the server](#start-the-server)
75-
+ [Alternative: run as systemd service](#alternative-run-as-systemd-service)
76-
+ [Web Usage](#web-usage)
77-
+ [IRC Usage](#irc-usage)
78-
* [Reference](#reference)
79-
+ [`bin/multistreamer` usage:](#binmultistreamer-usage)
80-
+ [Alternative install options:](#alternative-install-options)
81-
- [Remove Bash dependency](#remove-bash-dependency)
82-
* [Roadmap](#roadmap)
83-
* [Versioning](#versioning)
84-
* [Licensing](#licensing)
61+
- [multistreamer](#multistreamer)
62+
* [Table of Contents](#table-of-contents)
63+
* [Requirements](#requirements)
64+
* [Installation](#installation)
65+
+ [Install with Docker](#install-with-docker)
66+
+ [Install OpenResty with `setup-openresty`](#install-openresty-with-setup-openresty)
67+
+ [Alternative: Install OpenResty with RTMP Manually](#alternative-install-openresty-with-rtmp-manually)
68+
+ [Setup database and user in Postgres](#setup-database-and-user-in-postgres)
69+
+ [Setup Redis](#setup-redis)
70+
+ [Setup Sockexec](#setup-sockexec)
71+
+ [Setup Authentication Server](#setup-authentication-server)
72+
+ [Clone and setup](#clone-and-setup)
73+
+ [Install Multistreamer](#install-multistreamer)
74+
- [Global install](#global-install)
75+
- [Self-contained install](#self-contained-install)
76+
+ [Initialize the database](#initialize-the-database)
77+
+ [Customization](#customization)
78+
* [Usage](#usage)
79+
+ [Start the server](#start-the-server)
80+
+ [Alternative: run as systemd service](#alternative-run-as-systemd-service)
81+
+ [Web Usage](#web-usage)
82+
+ [IRC Usage](#irc-usage)
83+
* [Reference](#reference)
84+
+ [`bin/multistreamer` usage:](#binmultistreamer-usage)
85+
* [Roadmap](#roadmap)
86+
* [Versioning](#versioning)
87+
* [Licensing](#licensing)
8588

8689
## Requirements
8790

@@ -175,11 +178,11 @@ sudo make INSTALL_TOP="/opt/openresty-rtmp/luajit" TO_LIB="liblua.a liblua.so" i
175178

176179
cd ../luarocks-2.4.2
177180
./configure \
178-
--prefix=/opt/openresty-rtmp \
179-
--with-lua=/opt/openresty-rtmp/luajit \
180-
--rocks-tree=/opt/openresty-rtmp/luajit
181+
--prefix=/opt/openresty-rtmp/luajit \
182+
--with-lua=/opt/openresty-rtmp/luajit
181183
make build
182184
sudo make bootstrap
185+
sudo ln -s /opt/openresty-rtmp/luajit/bin/luarocks /opt/openresty-rtmp/bin/luarocks
183186
```
184187

185188
### Setup database and user in Postgres
@@ -250,7 +253,11 @@ http {
250253
I have some some projects for quickly setting up authentication servers:
251254

252255
* htpasswd: https://github.com/jprjr/htpasswd-auth-server
256+
* Authenticate users against an htpasswd file
257+
* postgres: https://github.com/jprjr/postgres-auth-server
258+
* Store users in postgres, includes a web interface for adding/managing users
253259
* LDAP: https://github.com/jprjr/ldap-auth-server
260+
* Authenticate users against LDAP
254261

255262

256263
### Clone and setup
@@ -260,94 +267,62 @@ Clone this repo somewhere, copy the example config file, and edit it as-needed
260267
```bash
261268
git clone https://github.com/jprjr/multistreamer.git
262269
cd multistreamer
263-
cp config.lua.example config.lua
264-
# edit config.lua
270+
cp etc/config.yaml.example /etc/multistreamer/config.yaml
271+
# edit /etc/multistreamer/config.yaml
265272
```
266273

267-
I've tried to comment `config.lua.example` and describe what each setting
274+
I've tried to comment `config.yaml.example` and describe what each setting
268275
does as best as I can.
269276

270-
The config file allows storing multiple environments in a single file,
271-
see http://leafo.net/lapis/reference/configuration.html for details.
272-
273277
One of the more important items in the config file is the `networks` section,
274278
right now the supported networks are:
275279

276-
* `facebook` - supports profiles and pages, auto-creates live video, pushes video.
277280
* `rtmp` - just push video to an RTMP URL
278-
* `twitch` - supports editing/updating channel information and pushing video
279-
* `youtube` - auto-creates live "events" and pushes video
281+
* `facebook`
282+
* `mixer`
283+
* `twitch`
284+
* `youtube`
280285

281286
Each module has more details in the [wiki.](https://github.com/jprjr/multistreamer/wiki)
282287

283-
### Install Lua modules
288+
### Install Multistreamer
289+
290+
#### Global install
291+
292+
```bash
293+
/opt/openresty/bin/luarocks install multistreamer
294+
```
284295

285-
You'll need some Lua modules installed:
296+
If you used the `setup-openresty` script from above, you'll find
297+
`multistreamer` at `/opt/openresty/bin/multistreamer`, else it
298+
depends on your particular setup.
286299

287-
* lua-resty-exec
288-
* lua-resty-jit-uuid
289-
* lua-resty-http
290-
* lapis
291-
* etlua
292-
* luaposix
293-
* luafilesystem
294-
* whereami
295300

296-
#### Installing locally
301+
#### Self-contained install
297302

298303
If you install modules to a folder named `lua_modules`, the bash script (`./bin/multistreamer`)
299304
setup nginx/Lua to only use that folder. So, assuming you're still in
300305
the `multistreamer` folder:
301306

302307
```bash
303-
/opt/openresty-rtmp/bin/luarocks install --tree=lua_modules --only-deps rockspecs/multistreamer-dev-1.rockspec
304-
```
305-
306-
307-
**Note**: older verions of LuaRocks might not automatically install dependencies.
308-
Here's the full list of modules, including dependencies:
309-
310-
```
311-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install bit32
312-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lua-cjson
313-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install date
314-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luacrypto
315-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install ansicolors
316-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lpeg
317-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install etlua
318-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install loadkit
319-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luafilesystem
320-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install mimetypes
321-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luasocket
322-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luabitop
323-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install pgmoon
324-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install netstring
325-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lua-resty-exec
326-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lua-resty-jit-uuid
327-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lua-resty-http
328-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install lapis
329-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install etlua
330-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luaposix
331-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install luafilesystem
332-
/opt/openresty-rtmp/bin/luarocks --tree=lua_modules install whereami
308+
/opt/openresty-rtmp/bin/luarocks install --tree=lua_modules --only-deps multistreamer
333309
```
334310

335311
Using Mac OS? `lapis` will probably fail to install because `luacrypto`
336312
will fail to build. If you're using Homebrew, you can install
337313
`luacrypto` with:
338314

339-
`luarocks --tree lua_modules install luacrypto OPENSSL_DIR=/usr/local/opt/openssl`
340-
341-
Then proceed to install `lapis`.
315+
```bash
316+
luarocks --tree=lua_modules install luacrypto OPENSSL_DIR=/usr/local/opt/openssl
317+
luarocks --tree=lua_modules install --only-dels multistreamer
342318

343-
### Initialize the database
319+
```
344320

345-
If you run `./bin/multistreamer -e <environment> initdb`, a new database will
346-
be created.
347321

348-
Alternatively, you could run something like:
322+
### Initialize the database
349323

350-
`psql -U <username> -h <host> -f sql/1477785578.sql`
324+
Multistreamer will automatically create tables when starting, or
325+
you can trigger them manually with `./bin/multistreamer initdb`
351326

352327
### Customization
353328

@@ -359,7 +334,7 @@ Just copy the `static` folder to `local`, then edit/replace files as needed.
359334

360335
### Start the server
361336

362-
Once it's been setup, you can start the server with `./bin/multistreamer -e <environment> run`
337+
Once it's been setup, you can start the server with `./bin/multistreamer run`
363338

364339
### Alternative: run as systemd service
365340

@@ -375,8 +350,8 @@ sudo useradd \
375350

376351
Then copy `misc/multistreamer.service` to
377352
`/etc/systemd/system/multistreamer.service`, and edit it as-needed - you'll
378-
probably need to change the `ExecStart` line to point to wherever you
379-
cloned the git repo.
353+
probably need to change the `ExecStart` and `ExecStartPre` lines to point
354+
to wherever you cloned the git repo.
380355

381356
### Web Usage
382357

@@ -451,34 +426,16 @@ Attached is a screenshot of Adium. I'm the user `john`, and my stream is named
451426
Here's the full list of options for `multistreamer`:
452427

453428
```
454-
multistreamer [-h] [-l /path/to/lua] -e <environment> <action>
429+
multistreamer [-l /path/to/lua] [-c /path/to/config.yaml] [-v] <action>
455430
```
456431

457-
* `-h` - displays help
458432
* `-l /path/to/lua` - explicitly provide a path to the lua/luajit binary
459-
* `-e <environment>` - one of the environments defined in `config.lua`
433+
* `-c /path/to/config.yaml`` - specify a config file, defaults to `/etc/multistreamer/config.yaml`
434+
* `-v` - prints the current version of multistreamer
460435
* `<action>` - can be one of
461436
* `run` - launches nginx
462-
* `initdb` - initialized the database
463-
* `psql` - starts up a psql session for your environment
464-
* `live <uuid>` - **internal**, the rtmp module calls this to setup
465-
and run ffmpeg.
466-
467-
468-
### Alternative install options:
469-
470-
#### Remove Bash dependency
471-
472-
The bash script at `bin/multistreamer` sets a few environment variables
473-
before calling `bin/multistreamer.lua`, and attempts to figure out which
474-
`lua` implementation to use.
475-
476-
If you can't or don't want to use bash you can call `bin/multistreamer.lua` - just
477-
be sure to set the following environment variables:
478-
479-
* `LAPIS_ENVIRONMENT` - required
480-
* `LUA_PACKAGE_PATH` - optional
481-
* `LUA_PACKAGE_CPATH` - optional
437+
* `initdb` - initializes the database
438+
* `check` - checks the config file, postgres, redis, etc
482439

483440
## Roadmap
484441

@@ -517,15 +474,6 @@ This project includes a copy of commonmark.js (`static/js/commonmark.min.js`),
517474
which is licensed under a BSD-style licnese. The commonmark.js license is
518475
available as LICENSE-commonmark-js
519476

520-
This project includes a copy of lua-resty-redis (`resty/redis.lua`),
521-
which is licensed under a BSD license. The license for lua-resty-redis is
522-
available as LICENSE-lua-resty-redis
523-
524-
This project includes a copy of lua-resty-websocket (`resty/websocket/protocol.lua`,
525-
`resty/websocket/client.lua`, `resty/websocket/server.lua`) which is license under
526-
a BSD license. The license for lua-resty-websocket is available as
527-
LICENSE-lua-resty-websocket.
528-
529477
This project includes a copy of zenscroll (`static/js/zenscroll-min.js`), which
530478
is public-domain code. The license for zenscroll is availble as LICENSE-zenscroll.
531479

bin/multistreamer

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,55 +47,47 @@ script_abs_name() {
4747
# }}}
4848

4949
usage() { # {{{
50-
printf "Usage:\n %s [-h] -e environment [-l /path/to/lua]\n" "$(script_name)"
51-
printf " -h - show this help\n"
52-
printf " -e <environment> - use environment from config.lua\n"
53-
printf " -l </path/to/lua> - specify lua binary\n"
50+
printf "Usage:\n %s [-l /path/to/lua]\n" "$(script_name)"
5451
} # }}}
5552

5653
install_dir=$(dirname $(script_abs_dir))
5754

58-
while getopts "he:l:" opt; do
55+
while getopts ":l:" opt; do
5956
case "$opt" in
60-
e) lapis_env=$OPTARG ;;
6157
l) lua_bin=$OPTARG ;;
62-
h) usage ; exit ;;
63-
\?) usage; exit ;;
6458
:) printf "Option -%s requires in argument\n" "${OPTARG}" >&2 ; exit 1;;
6559
esac
6660
done
6761

68-
shift $((OPTIND-1))
69-
70-
if [ -z "${lapis_env}" ] ; then
71-
usage
72-
exit 1
73-
fi
74-
75-
export LAPIS_ENVIRONMENT=${lapis_env}
76-
7762
if [ -z "${lua_bin}" ] ; then
7863
if command -v lua >/dev/null 2>&1; then
79-
if lua -e 'return true' ; then
80-
lua_bin=lua
81-
fi
64+
lua_bin=lua
8265
elif command -v luajit >/dev/null 2>&1; then
83-
if luajit -e 'return true' ; then
84-
lua_bin=luajit
85-
fi
66+
lua_bin=luajit
8667
else
8768
printf "Unable to find a suitable lua - please specify with -l /path/to/lua\n"
8869
exit 1
8970
fi
9071
fi
9172

92-
lua_bin=$(command -v ${lua_bin})
73+
export LUA_PATH=$("${lua_bin}" -e "print(package.path)")
74+
export LUA_CPATH=$("${lua_bin}" -e "print(package.cpath)")
9375

76+
# if 3rd-party modules in lua_modules, use it exclusively
9477
if [ -e "${install_dir}/lua_modules" ] ; then
9578
lua_major_ver=$(${lua_bin} -e "print(_VERSION:match('%d+%.%d+'))")
9679
export LUA_PATH="${install_dir}/lua_modules/share/lua/${lua_major_ver}/?.lua;${install_dir}/lua_modules/share/lua/${lua_major_ver}/?/init.lua;./?.lua;"
9780
export LUA_CPATH="${install_dir}/lua_modules/lib/lua/${lua_major_ver}/?.so;"
9881
fi
9982

100-
cd "${install_dir}"
101-
exec "${lua_bin}" "${install_dir}/bin/multistreamer.lua" "$@"
83+
# running from cloned directory, add local lib to search path
84+
if [ -e "${install_dir}/lib/multistreamer" ] ; then
85+
export LUA_PATH="${install_dir}/lib/?.lua;${install_dir}/lib/?/init.lua;${LUA_PATH}"
86+
export PATH="${install_dir}/bin:$PATH"
87+
fi
88+
89+
if [ -e "${install_dir}/share/multistreamer/html" ] ; then
90+
export MULTISTREAMER_STATIC_DIR="${install_dir}/share/multistreamer/html"
91+
fi
92+
93+
exec "${lua_bin}" "$(command -v multistreamer.lua)" "$@"

0 commit comments

Comments
 (0)