mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-26 05:27:35 +02:00
saving port to config
This commit is contained in:
parent
ca77700e2e
commit
46f99041cf
@ -4,12 +4,14 @@ import {ConfigLoader} from "./ConfigLoader";
|
|||||||
export class ConfigClass{
|
export class ConfigClass{
|
||||||
|
|
||||||
constructor(){
|
constructor(){
|
||||||
ConfigLoader.init(this,__dirname+'./../../../config.json');
|
ConfigLoader.init(this,__dirname+'./../../config.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
public thumbnailSizes = [200];
|
public port:number = 80;
|
||||||
public imagesFolder = "/demo/images";
|
|
||||||
public thumbnailFolder = "/demo/TEMP";
|
public thumbnailSizes:Array<number> = [200];
|
||||||
|
public imagesFolder:string = "/demo/images";
|
||||||
|
public thumbnailFolder:string = "/demo/TEMP";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,9 @@ import {PublicRouter} from "./routes/PublicRouter";
|
|||||||
import {UserRouter} from "./routes/UserRouter";
|
import {UserRouter} from "./routes/UserRouter";
|
||||||
import {GalleryRouter} from "./routes/GalleryRouter";
|
import {GalleryRouter} from "./routes/GalleryRouter";
|
||||||
import {AdminRouter} from "./routes/AdminRouter";
|
import {AdminRouter} from "./routes/AdminRouter";
|
||||||
import {Error} from "../common/entities/Error";
|
|
||||||
import {json} from "body-parser";
|
|
||||||
import {ErrorRouter} from "./routes/ErrorRouter";
|
import {ErrorRouter} from "./routes/ErrorRouter";
|
||||||
import {SharingRouter} from "./routes/SharingRouter";
|
import {SharingRouter} from "./routes/SharingRouter";
|
||||||
|
import {Config} from "./config/Config";
|
||||||
|
|
||||||
|
|
||||||
export class Server {
|
export class Server {
|
||||||
@ -71,14 +70,13 @@ export class Server {
|
|||||||
|
|
||||||
|
|
||||||
// Get port from environment and store in Express.
|
// Get port from environment and store in Express.
|
||||||
this.port = Server.normalizePort(process.env.PORT || '80');
|
this.app.set('port', Config.port);
|
||||||
this.app.set('port', this.port);
|
|
||||||
|
|
||||||
// Create HTTP server.
|
// Create HTTP server.
|
||||||
this.server = _http.createServer(this.app);
|
this.server = _http.createServer(this.app);
|
||||||
|
|
||||||
//Listen on provided port, on all network interfaces.
|
//Listen on provided port, on all network interfaces.
|
||||||
this.server.listen(this.port);
|
this.server.listen(Config.port);
|
||||||
this.server.on('error', this.onError);
|
this.server.on('error', this.onError);
|
||||||
this.server.on('listening', this.onListening);
|
this.server.on('listening', this.onListening);
|
||||||
|
|
||||||
@ -86,24 +84,7 @@ export class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize a port into a number, string, or false.
|
|
||||||
*/
|
|
||||||
private static normalizePort(val) {
|
|
||||||
var port = parseInt(val, 10);
|
|
||||||
|
|
||||||
if (isNaN(port)) {
|
|
||||||
// named pipe
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port >= 0) {
|
|
||||||
// port number
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event listener for HTTP server "error" event.
|
* Event listener for HTTP server "error" event.
|
||||||
@ -113,9 +94,9 @@ export class Server {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bind = typeof this.port === 'string'
|
var bind = typeof Config.port === 'string'
|
||||||
? 'Pipe ' + this.port
|
? 'Pipe ' + Config.port
|
||||||
: 'Port ' + this.port;
|
: 'Port ' + Config.port;
|
||||||
|
|
||||||
// handle specific listen error with friendly messages
|
// handle specific listen error with friendly messages
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user