move wss server start after http
This commit is contained in:
		@@ -428,9 +428,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (argv.serve) {
 | 
					    if (argv.serve) {
 | 
				
			||||||
      const wss = new WebSocketServer({ port: 3001 })
 | 
					 | 
				
			||||||
      const connections = []
 | 
					      const connections = []
 | 
				
			||||||
      wss.on("connection", (ws) => connections.push(ws))
 | 
					 | 
				
			||||||
      const clientRefresh = () => connections.forEach((conn) => conn.send("rebuild"))
 | 
					      const clientRefresh = () => connections.forEach((conn) => conn.send("rebuild"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (argv.baseDir !== "" && !argv.baseDir.startsWith("/")) {
 | 
					      if (argv.baseDir !== "" && !argv.baseDir.startsWith("/")) {
 | 
				
			||||||
@@ -515,6 +513,8 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started.
 | 
				
			|||||||
        return serve()
 | 
					        return serve()
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      server.listen(argv.port)
 | 
					      server.listen(argv.port)
 | 
				
			||||||
 | 
					      const wss = new WebSocketServer({ port: 3001 })
 | 
				
			||||||
 | 
					      wss.on("connection", (ws) => connections.push(ws))
 | 
				
			||||||
      console.log(
 | 
					      console.log(
 | 
				
			||||||
        chalk.cyan(
 | 
					        chalk.cyan(
 | 
				
			||||||
          `Started a Quartz server listening at http://localhost:${argv.port}${argv.baseDir}`,
 | 
					          `Started a Quartz server listening at http://localhost:${argv.port}${argv.baseDir}`,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user