Skip to content

Commit

Permalink
Update Infoscreen3 to 1.6.4
Browse files Browse the repository at this point in the history
* Update npm dependencies
* Change config to use environmental variables,
* Fix videos to actually show (modern browsers needs muted volume)
* Fix videos to load actually for lite and css views
* Provide zip with precompiled binaries for super-easy setup
  • Loading branch information
reaby committed Nov 12, 2023
1 parent 383d912 commit a0875f8
Show file tree
Hide file tree
Showing 33 changed files with 10,959 additions and 2,924 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NODE_ENV=production
DEBUG=false
HOST="127.0.0.1"
PORT=3000
ADMIN_USER="admin"
ADMIN_PASS="admin"
LOCALE=en
MEDIASERVER=false
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ typings/
# own additions
.idea
.vscode
config.js
tmp/*.png
public/assets/
data/sessions.db
Expand All @@ -74,4 +73,6 @@ data/template.json
!data/bundles/default/*
data/video/*.mp4
trash/*
!trash/.gitkeep
!trash/.gitkeep
webpack
dist
9 changes: 9 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# BUILD

## Prequisities

1. `npm i pgk -g`

## Build excutable

1. `npm run build`
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,17 @@ When you need to display same content to multiple locations or need to remotely

## Setup
1. run `npm install`
2. copy `config-default.js` to `config.js`
2. copy `.env.example` to `.env`
3. run `npm start`
- optionally you can start as a background task: `npm run-script daemon`, it will output just a pid for the new process and you find new files: `output.log` and `errors.log` at the `data` directory.

## Configuration
> The default `config.js` file serves you well only if you wish to run infoscreen at localhost only!

To access the infoscreen server outside from the localhost, like at LAN network, the config must be bind to external IP your server machine has.
To access the infoscreen server outside from the localhost, like at LAN network, the config must be bind to external IP your server machine has. Configuration is set by environmental variables or by editing `.env` file.

Example:
```javascript
module.exports = {
"serverListenPort": 8000,
"serverHost": "192.168.56.100",
// ...config file continues from here...
```
If you wish to have live stream support at local network using OBS, set `mediaServer` to `true` and set desired streamKey
You can run the server listen port as well the default http port `80`, but in that case you have to run the app with privileges at linux systems: `sudo npm start`
If you wish to have live stream support at local network using OBS, set `MEDIASERVER` to `true` and set desired streamKey

You can run the server listen port as well the default http port `80`, but in that case you have to run the app with privileges with linux systems: `sudo npm start`

## Plugins

Expand Down Expand Up @@ -75,22 +68,30 @@ at OBS go to `Settings` -> `Stream`
| Stream key | config.streamKey value, defaults to: `INFOSCREEN3` |
| Use Authentication | *leave un-ticked* |

### Note
Use only **baseline**-encoding for H.264, other options not works with the embedded javascript player

## Mediaserver admin panel
> if you have changed the default port from 8000 to something else, the correct port to access this feature is (config.serverListenPort+1)
Admin interface is located at: http://localhost:8001/admin
It accepts the same crendetials as configured at the main app.

## Environment variables
| ENV | default | Usage |
| :---------- | :-------- | :---------------------------------------------------- |
| PORT | 8000 | Server listen port |
| HOST | localhost | Host or ip, where the server is externally accessible |
| ADMIN_USER | admin | Username to access admin interface |
| ADMIN_PASS | admin | Password for the admin interface |
| USER | view | Username to access viewer |
| PASS | view | Password to access viewer |
| FRONT_PROXY | false | Tell software that it's behind a front proxy |
| ENV | default | Usage |
| :---------- | :-------- | :---------------------------------------------------- |
| PORT | 8000 | Server listen port |
| HOST | localhost | Host or ip, where the server is externally accessible |
| ADMIN_USER | admin | Username to access admin interface |
| ADMIN_PASS | admin | Password for the admin interface |
| USER | view | Username to access viewer |
| PASS | view | Password to access viewer |
| FRONT_PROXY | false | Tell software that it's behind a front proxy |
| DEBUG | false | whatever to debug... or not |
| SESSIONKEY | predefined | used to encrypt cookies |
| STREAMKEY | INFOSCREEN3 | streamkey used at OBS |
| MEDIASERVER | false | use streaming feature |
| LOCALE | en | available locales: en, fi |

## Dockerfile

Expand Down
13 changes: 6 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import config from './config.js';
import express from 'express';
import createError from 'http-errors';
import logger from 'morgan';
import lessMiddleware from 'less-middleware';
import path from 'path';
import PluginManager from './modules/pluginManager.js';
const app = express();
Expand All @@ -30,7 +29,7 @@ import CookieParser from 'cookie-parser';
import Http from 'http';
import { Server as SocketIO } from 'socket.io';
import i18next from 'i18next';
import FilesystemBackend from 'i18next-node-fs-backend';
import FilesystemBackend from 'i18next-fs-backend';
import i18nextMiddleware from 'i18next-http-middleware';
import passport from 'passport';
import passportlocal from 'passport-local';
Expand Down Expand Up @@ -83,22 +82,23 @@ passport.use("local", new LocalStrategy({
if (config.mediaServer) {
const nodeServerConfig = {
logtype: 2,
allow_origin: '*',
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 30
ping_timeout: 30,

},
http: {
port: (parseInt(config.serverListenPort) + 1),
allow_origin: '*',
allow_origin: '*',
},
auth: {
api: true,
api_user: config.admins[0].username,
api_pass: config.admins[0].password,

}
};

Expand Down Expand Up @@ -148,14 +148,13 @@ app.set('port', parseInt(config.serverListenPort));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'twig');
app.use(i18nextMiddleware.handle(i18next));
app.use(logger('dev'));
//app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({
extended: false
}));

app.use(cookieParser);
app.use(lessMiddleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));
app.use("/video/",express.static(path.join(__dirname, 'data','video')));

Expand Down
13 changes: 13 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "infoscreen3",
"version": "1.6.4",
"private": true,
"bin": "./webpack/bundle.js",
"module": "false",
"pkg": {
"scripts": ["./webpack/*.bundle.js", "./node_modules/socket.io/"],
"assets": ["./node_modules/socket.io/"],
"targets": [ "node18-windows-x64", "node18-linux-x64"],
"outputPath": "dist"
}
}
13 changes: 13 additions & 0 deletions compile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { execSync } from 'child_process';
import fs from "fs-extra";

console.log("Copying files...");
const toCopy = ["data", "locales", "templates", "tmp", "trash", ".env"];

for (const dir of toCopy) {
console.log(`Copying ${dir}...`);
fs.cpSync(`./${dir}`, `./dist/${dir}`, {
recursive: true
});
console.log("done.");
}
11 changes: 6 additions & 5 deletions config-default.js → config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dotenv/config'

const host = "127.0.0.1" // ip of the infoscreen interface, use external address if not develoment
const port = 8000; // port for infoscreen
Expand All @@ -10,17 +11,17 @@ export default {
"serverListenPort": process.env.PORT || port,
"serverHost": process.env.HOST || host,
"serverUrl": hostUrl,
"sessionKey": "generateRandomStringForSecret", // used for encrypting cookies
"streamKey": 'INFOSCREEN3', // stream key for rtmp end point
"sessionKey": process.env.SESSIONKEY || "generateSecret", // used for encrypting cookies
"streamKey": process.env.STREAMKEY || 'INFOSCREEN3', // stream key for rtmp end point
"useLocalAssets": false, // used to load javascript libraries locally from /public/assets
"mediaServer": false, // local streaming server for rtmp, see docs how to use
"defaultLocale": "en", // currently supported values are: "en","fi"
"mediaServer": (process.env.MEDIASERVER == "true") ? true : false, // local streaming server for rtmp, see docs how to use
"defaultLocale": process.env.LOCALE || "en", // currently supported values are: "en","fi"

/*
* Plugins
*/
"plugins": [
"profiler", // display memory statistics at console.
// "profiler", // display memory statistics at console.
],

/*
Expand Down
2 changes: 1 addition & 1 deletion bin/daemon.js → daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import { daemon } from 'daemon';
var stdoutFd = fs.openSync('./data/output.log', 'a');
var stderrFd = fs.openSync('./data/errors.log', 'a');
var proc2 = daemon("./bin/infoscreen3",
var proc2 = daemon("./infoscreen3",
"",
{
cwd: process.cwd(),
Expand Down
11 changes: 4 additions & 7 deletions bin/infoscreen3.js → infoscreen3.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
/**
* Module dependencies.
*/
import cli from '../modules/cli.js';
import chalk from 'chalk';
import config from '../config.js';
import { app, server } from "../app.js";
import config from './config.js';
import { app, server } from "./app.js";


/**
Expand All @@ -20,7 +19,6 @@ app.set('port', port);
* Create HTTP server.
*/


/**
* Listen on provided port, on all network interfaces.
*/
Expand Down Expand Up @@ -85,8 +83,7 @@ function onListening() {
let addr = server.address();
let bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;

cli.info('Infoscreen is now accessible at ' + chalk.bold.white(config.serverUrl));
: 'port ' + addr.port;
console.log('Infoscreen is now accessible at ' + chalk.bold.white(config.serverUrl));
console.log(chalk.green(">>") + chalk.white("Start complete.") + chalk.green("<<"));
}
5 changes: 3 additions & 2 deletions modules/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ export default class admin {

if (serverOptions.isStreaming === false) {
serverOptions.loop = false;
// changed next line from http:// to ws://, to reduce stream lag
serverOptions.streamSource = "ws://" + config.serverHost + ":" + (config.serverListenPort + 1) + "/live/" + config.streamKey + ".flv";
// changed next line from http:// to ws://, to reduce stream lag

serverOptions.streamSource = "http://" + config.serverHost + ":" + (config.serverListenPort + 1) + "//" + config.streamKey + ".flv";
serverOptions.isStreaming = true;
cli.success("start stream");
} else {
Expand Down
16 changes: 8 additions & 8 deletions modules/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class bundleClass {

getSlideJsonFile(fileName) {
try {
return fs.readFileSync("./data/bundles/" + this.name + "/slides/" + fileName).toString();
return fs.readFileSync(process.cwd() + "/data/bundles/" + this.name + "/slides/" + fileName).toString();
} catch (err) {
return "{}";
}
Expand All @@ -48,7 +48,7 @@ export default class bundleClass {
if (slide.uuid === uuid) {
if (slide.type === "slide") {
let newId = uuidv4();
let path = "./data/bundles/" + this.name;
let path = process.cwd() + "/data/bundles/" + this.name;
try {
// duplicate at filesystem
if (fs.existsSync(path + "/render/" + uuid + ".png")) {
Expand All @@ -72,8 +72,8 @@ export default class bundleClass {
}

moveTo(bundleDir, uuid) {
let toPath = "./data/bundles/" + bundleDir;
let path = "./data/bundles/" + this.name;
let toPath = process.cwd() +"/data/bundles/" + bundleDir;
let path = process.cwd() + "/data/bundles/" + this.name;
for (let slide of this.allSlides) {
if (slide.uuid === uuid) {
try {
Expand Down Expand Up @@ -109,7 +109,7 @@ export default class bundleClass {
}
if (slide.uuid === uuid) {
if (slide.type === "slide") {
let path = "./data/bundles/" + this.name;
let path = process.cwd() + "/data/bundles/" + this.name;
try {
if (fs.existsSync(path + "/render/" + uuid + ".png")) {
fs.unlinkSync(path + "/render/" + uuid + ".png");
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class bundleClass {
if (slide.uuid === uuid) {
slideData = {
settings: slide,
render: fs.readFileSync("./data/bundles/" + this.name + "/slides/" + slide.uuid + ".png")
render: fs.readFileSync(process.cwd() + "/data/bundles/" + this.name + "/slides/" + slide.uuid + ".png")
};
return slide;
}
Expand All @@ -211,8 +211,8 @@ export default class bundleClass {
save() {
this.sync();
try {
fs.writeFileSync("./data/bundles/" + this.name + "/slides.json", JSON.stringify(this.allSlides, null, "\t"));
fs.writeFileSync("./data/bundles/" + this.name + "/bundle.json", JSON.stringify(this.bundleData, null, "\t"));
fs.writeFileSync(process.cwd() + "/data/bundles/" + this.name + "/slides.json", JSON.stringify(this.allSlides, null, "\t"));
fs.writeFileSync(process.cwd() + "/data/bundles/" + this.name + "/bundle.json", JSON.stringify(this.bundleData, null, "\t"));
} catch (e) {
cli.error("error while saving file:", e);
}
Expand Down
2 changes: 2 additions & 0 deletions modules/cli.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dotenv/config'
import chalk from 'chalk';
let lastStamp = "";

Expand All @@ -23,6 +24,7 @@ export default {
},

log: function (string) {
if (process.env.DEBUG != "true") return;
let now = getDateTime();
if (lastStamp != now) {
lastStamp = now;
Expand Down
Loading

0 comments on commit a0875f8

Please sign in to comment.