Listened SERVER_PORT env variable on applications servers
This commit is contained in:
parent
820e9585ac
commit
e66c713ea8
@ -8,6 +8,16 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
|
||||
IConfiguration config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.AddEnvironmentVariables().Build();
|
||||
|
||||
// Load env variables
|
||||
var SERVER_PORT = config.GetValue<int>("SERVER_PORT");
|
||||
var OPENVIDU_URL = config.GetValue<string>("OPENVIDU_URL");
|
||||
var OPENVIDU_SECRET = config.GetValue<string>("OPENVIDU_SECRET");
|
||||
|
||||
// Enable CORS support
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
@ -18,17 +28,13 @@ builder.Services.AddCors(options =>
|
||||
});
|
||||
});
|
||||
|
||||
builder.WebHost.UseKestrel(serverOptions => {
|
||||
serverOptions.ListenAnyIP(SERVER_PORT);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseCors(MyAllowSpecificOrigins);
|
||||
|
||||
IConfiguration config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.AddEnvironmentVariables().Build();
|
||||
|
||||
// Load env variables
|
||||
var OPENVIDU_URL = config.GetValue<string>("OPENVIDU_URL");
|
||||
var OPENVIDU_SECRET = config.GetValue<string>("OPENVIDU_SECRET");
|
||||
|
||||
// Allow for insecure certificate in OpenVidu deployment
|
||||
var handler = new HttpClientHandler
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
SERVER_PORT=5000
|
||||
OPENVIDU_URL=http://localhost:4443/
|
||||
OPENVIDU_SECRET=MY_SECRET
|
||||
@ -6,6 +6,13 @@ var OpenVidu = require("openvidu-node-client").OpenVidu;
|
||||
var cors = require("cors");
|
||||
var app = express();
|
||||
|
||||
// Environment variable: PORT where the node server is listening
|
||||
var SERVER_PORT = process.env.SERVER_PORT || 5000;
|
||||
// Environment variable: URL where our OpenVidu server is listening
|
||||
var OPENVIDU_URL = process.env.OPENVIDU_URL || 'http://localhost:4443';
|
||||
// Environment variable: secret shared with our OpenVidu server
|
||||
var OPENVIDU_SECRET = process.env.OPENVIDU_SECRET || 'MY_SECRET';
|
||||
|
||||
// Enable CORS support
|
||||
app.use(
|
||||
cors({
|
||||
@ -14,6 +21,7 @@ app.use(
|
||||
);
|
||||
|
||||
var server = http.createServer(app);
|
||||
var openvidu = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
||||
|
||||
// Allow application/x-www-form-urlencoded
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
@ -24,17 +32,11 @@ app.use(bodyParser.json());
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
|
||||
// Serve application
|
||||
server.listen(5000, () => {
|
||||
console.log("Application started");
|
||||
server.listen(SERVER_PORT, () => {
|
||||
console.log("Application started on port: ", SERVER_PORT);
|
||||
console.warn('Application server connecting to OpenVidu at ' + OPENVIDU_URL);
|
||||
});
|
||||
|
||||
console.warn('Application server connecting to OpenVidu at ' + process.env.OPENVIDU_URL);
|
||||
|
||||
var openvidu = new OpenVidu(
|
||||
process.env.OPENVIDU_URL,
|
||||
process.env.OPENVIDU_SECRET
|
||||
);
|
||||
|
||||
app.post("/api/sessions", async (req, res) => {
|
||||
var session = await openvidu.createSession(req.body);
|
||||
res.send(session.sessionId);
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
OPENVIDU_URL=5000
|
||||
OPENVIDU_URL=http://localhost:4443/
|
||||
OPENVIDU_SECRET=MY_SECRET
|
||||
@ -9,6 +9,7 @@ app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/*": {"origins": "*"}})
|
||||
|
||||
# Load env variables
|
||||
SERVER_PORT = os.environ.get("SERVER_PORT")
|
||||
OPENVIDU_URL = os.environ.get("OPENVIDU_URL")
|
||||
OPENVIDU_SECRET = os.environ.get("OPENVIDU_SECRET")
|
||||
|
||||
@ -47,4 +48,4 @@ def createConnection(sessionId):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0")
|
||||
app.run(debug=True, host="0.0.0.0", port=SERVER_PORT)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user