Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import neko.io.Process;
- import neko.vm.Thread;
- class HaxeServer
- {
- public static var port = "4444";
- static var thread:Thread;
- public static function start()
- {
- #if haxe_209
- if (thread == null)
- {
- Sys.println("Starting compilation server on port " + port);
- thread = Thread.create(main);
- }
- #end
- }
- public static function stop()
- {
- if (thread != null)
- {
- Sys.println("Killing compilation server on port " + port);
- thread.sendMessage("kill");
- thread = null;
- }
- }
- static function main()
- {
- var process = new Process("haxe", ["--wait", port]);
- while (Thread.readMessage(false) != "kill") Sys.sleep(0.1);
- process.kill();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement