docs(xapi): improve VM Sync Hook example server
This commit is contained in:
parent
0197758780
commit
c52e0a5531
@ -49,6 +49,8 @@ The created snapshot will have the special `xo:synced` tag set to make it identi
|
|||||||
|
|
||||||
## Example server in Node
|
## Example server in Node
|
||||||
|
|
||||||
|
> This server requires [Node.js](https://nodejs.org/en/download/) to be installed on your system.
|
||||||
|
|
||||||
`index.cjs`:
|
`index.cjs`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -123,9 +125,25 @@ async function main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
server.on('close', resolve).on('error', reject).listen(1727)
|
server
|
||||||
|
.on('close', resolve)
|
||||||
|
.on('error', reject)
|
||||||
|
.listen(1727, () => {
|
||||||
|
let { address, port } = server.address()
|
||||||
|
if (address.includes(':')) {
|
||||||
|
address = `[${address}]`
|
||||||
|
}
|
||||||
|
console.log('Server is listening on https://%s:%s', address, port)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(console.warn)
|
main().catch(console.warn)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can run it manually for testing:
|
||||||
|
|
||||||
|
```
|
||||||
|
> node index.cjs
|
||||||
|
Server is listening on https://[::]:1727
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user