Add config option to turn server side rendering off.

Ensure templates are precompiled before starting the server.
This commit is contained in:
knotteye
2020-10-16 21:31:23 -05:00
parent 4ec89d71f8
commit 961b5fe648
5 changed files with 22 additions and 6 deletions

View File

@@ -1,8 +1,9 @@
import * as db from "./database";
import {readdirSync} from "fs";
import { execSync } from "child_process";
async function init(m?: boolean) {
if(!m){
async function init() {
if(process.argv.indexOf('--skip-migrate') === -1){
console.log('Checking database version.');
var tmp: string[] = await db.query('show tables like \"db_meta\"');
if(tmp.length === 0){
@@ -17,6 +18,15 @@ async function init(m?: boolean) {
else {
console.log('Skipping database version check.');
}
if(!require('./config').config['http']['server_side_render'] && process.argv.indexOf('--skip-compile') === -1) {
console.log("Compiling templates for client-side frontend.");
execSync(process.cwd()+'/node_modules/.bin/nunjucks-precompile -i [\"\\.html$\",\"\\.njk$\"] templates > site/templates.js');
}
else if(!require('./config').config['http']['server_side_render']){
console.log("Skipped compiling templates for client-side frontend.");
}
//If satyr is restarted in the middle of a stream
//it causes problems
//Live flags in the database stay live

View File

@@ -36,7 +36,10 @@ const config: Object = {
ping: 30,
ping_timeout: 60 }, localconfig['rtmp']),
http: Object.assign({
hsts: false, directory: './site', port: 8000
hsts: false,
directory: './site',
port: 8000,
server_side_render: true
}, localconfig['http']),
media: Object.assign({
record: false,

View File

@@ -7,7 +7,7 @@ import { config } from "./config";
async function run() {
await initDB();
await clean(process.argv.indexOf('--skip-migrate') !== -1);
await clean();
await initHTTP();
await initRTMP();
await initChat();