Skip to content

Commit

Permalink
Update MongoDb configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanngd committed Jul 31, 2020
1 parent cabb5a2 commit 661b0c1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
3 changes: 2 additions & 1 deletion client/components/LiveStreams.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default class Navbar extends React.Component {
}

getLiveStreams() {
axios.get('http://127.0.0.1:' + config.rtmp_server.http.port + '/api/streams')
let streamApi = 'http://' + config.server.host + ':' + config.rtmp_server.http.port + '/api/streams';
axios.get(streamApi)
.then(res => {
let streams = res.data;
if (typeof (streams['live'] !== 'undefined')) {
Expand Down
20 changes: 19 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ $ ffmpeg --version

[Mac](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/)

#### Setup mongodb with docker

```
docker run -d -it --name mongodb \
-p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=admin \
mongo
```

#### Configuration
Change ffmpeg path in node media server configuration to your
own installed path.
Expand All @@ -40,7 +50,15 @@ cd nodeStream && nano /server/config/default.js
const config = {
server: {
secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc',
port : 3333
port: '3333',
host: 'localhost',
},
mongodb: {
host: 'localhost',
port: '27017',
userName: 'admin',
password: 'admin',
},
rtmp_server: {
rtmp: {
Expand Down
2 changes: 1 addition & 1 deletion server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ app.get('*', middleware.ensureLoggedIn(), (req, res) => {
res.render('index');
});

app.listen(port, () => console.log(`App listening on ${port}!`));
app.listen(port, () => console.log(`App listening on ${config.server.host}:${port}!`));
node_media_server.run();
thumbnail_generator.start();
10 changes: 9 additions & 1 deletion server/config/default.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const config = {
server: {
secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc',
port : 3333
port: '3333',
host: 'localhost',
},
mongodb: {
host: 'localhost',
port: '27017',
userName: 'admin',
password: 'admin',

},
rtmp_server: {
rtmp: {
Expand Down
17 changes: 17 additions & 0 deletions server/database/Schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
let mongoose = require('mongoose');
const config = require('../config/default');

const connectMongoDB = () => {
mongoose.connect(
`mongodb://${config.mongodb.userName}:${config.mongodb.password}@${config.mongodb.host}:${config.mongodb.port}`,
{
useNewUrlParser: true,
useUnifiedTopology: true
}
).then(() => {
console.log("Connected to mongodb");
}).catch((err) => {
console.log(err);
});
}

connectMongoDB();

exports.User = mongoose.model('User', require('./UserSchema'));

0 comments on commit 661b0c1

Please sign in to comment.