forked from devleague/react-kanban
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy-dev.js
48 lines (44 loc) · 1018 Bytes
/
deploy-dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const nodemon = require('nodemon');
const knex = require('./server/database/knex');
const DELAY = 3000;
function testConnection() {
return new Promise((resolve) => {
setTimeout(() => {
console.log('Polling for DB Connection...');
knex.migrate.latest()
.then(resolve)
.catch((err) => {
console.log(err);
resolve(testConnection());
});
}, DELAY);
})
}
// migrate db
testConnection()
// run seeds
.then(() => { knex.seed.run(); })
// print status
.then(() => {
console.log('Migration and Seeds Finished');
})
// run server using nodemon
.then(() => {
nodemon({
script: './server/server.js',
ext: 'js json',
ignore: ['src/'],
});
nodemon.on('start', function () {
console.log('App has started');
}).on('quit', function () {
console.log('App has quit');
process.exit();
}).on('restart', function (files) {
console.log('App restarted due to: ', files);
});
})
.catch((err) => {
console.log(err);
process.exit(1);
});