forked from OriginProtocol/origin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
41 lines (34 loc) · 1.04 KB
/
index.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
import express from 'express'
import serveStatic from 'serve-static'
import { spawn } from 'child_process'
import opener from 'opener'
import fs from 'fs'
import services from '@origin/services'
const HOST = process.env.HOST || 'localhost'
const app = express()
app.get('/', (req, res) => {
const html = fs.readFileSync(__dirname + '/public/dev.html').toString()
res.send(html.replace(/\{HOST\}/g, `http://${HOST}:8082/`))
})
app.use(serveStatic('public'))
async function start() {
await services({
ganache: true,
deployContracts: true,
ipfs: true,
populate: true,
skipContractsIfExists: process.env.CLEAN ? false : true
})
const webpackDevServer = spawn(
'./node_modules/.bin/webpack-dev-server',
['--info=false', '--port=8082', '--host=0.0.0.0'],
{ stdio: 'inherit' }
)
process.on('exit', () => webpackDevServer.kill())
const PORT = process.env.PORT || 3001
app.listen(PORT, () => {
console.log(`\nListening on port ${PORT}\n`)
setTimeout(() => opener(`http://${HOST}:${PORT}`), 2000)
})
}
start()