Last active
May 30, 2021 08:10
-
-
Save hoangsetup/8dc012ef77d104765b6969aaf0311999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Server as HttpServer } from "http"; | |
import { Server } from "socket.io"; | |
import pm2Lib, { IProcessOutLog } from "./pm2Lib"; | |
class SocketIO { | |
private io: Server | undefined; | |
init(httpServer: HttpServer) { | |
if (this.io !== undefined) { | |
throw new Error('Socket server already defined!'); | |
} | |
this.io = new Server(httpServer); | |
pm2Lib.onLogOut((procLog: IProcessOutLog) => { | |
this.io?.emit(`${procLog.process.name}:out_log`, procLog); | |
}); | |
} | |
} | |
export default new SocketIO(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment