// main entry creates and launches the server static void Main(string[] args) { Console.WriteLine("Andl Thrift Server"); Logger.Open(0); // no default logging var options = OptionParser.Create(_options, Help); if (!options.Parse(args)) { return; } GatewayBase gateway = null; try { gateway = AppStartup(options.GetPath(0), _settings); Processor processor = new Processor(gateway); TServerTransport serverTransport = new TServerSocket(ServerPort); // There are several different servers available. They should all work. Server = new TThreadPoolServer(processor, serverTransport); //TServer server = new TThreadPoolServer(processor, serverTransport); //TServer server = new TThreadPoolServer(processor, serverTransport, new TTransportFactory(), new TCompactProtocol.Factory()); //TServer server = new TThreadedServer(processor, serverTransport); //TServer server = new TSimpleServer(processor, serverTransport); Server.setEventHandler(new ServerEventHandler()); gateway.OpenSession(); Console.WriteLine($"Starting server...database '{gateway.DatabaseName}' {gateway.DatabaseKind}"); Server.Serve(); gateway.CloseSession(true); } catch (ProgramException ex) { Console.WriteLine(ex.ToString()); if (gateway != null) { gateway.CloseSession(false); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); if (gateway != null) { gateway.CloseSession(false); } } Console.WriteLine("done."); }
//------------------------------------------------------------------------- // mainline // start up web host, then run tests static void Main(string[] args) { Logger.Open(0); // no default logging Logger.WriteLine("Andl.Host"); var options = OptionParser.Create(_options, Help); if (!options.Parse(args)) { return; } try { AppStartup(options.GetPath(0), _settings); _gateway.OpenSession(); string address = $"http://{Environment.MachineName}:{ServerPort}/api"; Logger.WriteLine(1, $"Opening host with database: {_gateway.DatabaseName} ({_gateway.DatabaseKind}) address: {address}"); var host = CreateHost(address, ""); host.Open(); Logger.WriteLine(1, "Host opened."); if (!NoTests) { SendTests(address); } Console.WriteLine("Server is waiting for requests. Press Enter to close."); Console.ReadLine(); host.Close(); _gateway.CloseSession(); } catch (ProgramException ex) { Console.WriteLine(ex.ToString()); if (_gateway != null) { _gateway.CloseSession(false); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); if (_gateway != null) { _gateway.CloseSession(false); } } }
static void Main(string[] args) { _out.WriteLine(Version); var options = OptionParser.Create(_options, _help); if (!options.Parse(args)) { return; } if (_xdebug) { options.Parse(new string[] { "/verbose", "36772507" }); // crate move //options.Parse(new string[] { "/verbose", "36772507", "test.wav" }); // crate move } if (options.PathsCount < 1) { _out.WriteLine("Must specify seed"); } else { var nsound = options.GetPath(0).SafeIntParse() ?? 0; var filename = options.GetPath(1) ?? options.GetPath(0); if (!Path.HasExtension(filename)) { filename = Path.ChangeExtension(filename, ".wav"); } if (!_seedlookup.ContainsKey(nsound % 100)) { _out.WriteLine("Invalid seed"); } else { DoGenerate(nsound, filename); } } }
static void Main(string[] args) { Logger.Open(1); _output = Console.Out; _output.WriteLine(PolyVersion); var options = OptionParser.Create(_options, Help); if (!options.Parse(args)) { return; } var Path = options.GetPath(0) ?? DefaultPath; try { //PlayTTTGames(); Logger.Level = 0; //Logger.Level = 3; // compile logging //Load(@"TicTacToe.txt", 10).Play(23, 11, 3); // beer game with logging //Load(@"TicTacToe.txt", 1).Play(31, 0, 1); // scan losers TTT with logging //Load(@"TicTacToe.txt", 0).Play(1, 0, 3); // losers TTT with logging //Load(@"..\GamesZrf\Breakthrough.zrf", 0, 2).Play(0, 0, 3); // Breakthrough with logging //Load(@"TicTacToe.txt", 0, 1).Play(1, 0, 3); //CreateGameTTT("ttt", "", "", 4).Play(0); var xx = 50; // create and run test game if (xx == 10) { CreateTestGame("xxx", 4); } if (xx == 11) { CreateTestGame("xxx", 4).Switch(0, 0, 2); } // compile one and do something if (xx == 20) { CompileAndAct(SearchFolders(@"..\Unity\test games", 4, 1), 0, 1, pw => pw.Switch(0, 0, 4)); } if (xx == 21) { CompileAndAct(SearchFolders(@"..\Unity\test games", 4, 1), 0, 0, pw => pw.Switch(1, 1, 2)); } if (xx == 22) { CompileAndAct(SearchFolders(@"..\GamesPoly", 0, 1), 0, 4, pw => pw.Switch(1, 0, 5)); } // interactive selection if (xx == 30) { CompileAndAsk(SearchFolders(@"..\Unity\test games"), 1, pw => pw.Switch(1, 0, 3)); } if (xx == 31) { CompileAndAsk(SearchFolders(@"..\GamesPoly"), 1, pw => pw.Switch(1, 0, 3)); } // pick one and go //if (xx == 50) CompileAndAct(SearchFolders(@"..\Unity\test games", contains: "fruit"), 0, 0, pw => pw.Switch(1, 0, 4)); //if (xx == 50) CompileAndAct(SearchFolders(@"..\Unity\test games", contains: "cave_"), 0, 0, pw => pw.Switch(1, 0, 3)); if (xx == 50) { CompileAndAct(SearchFolders(@"..\Unity\test games", contains: "hex_"), 0, 0, pw => pw.Switch(1, 0, 3)); } // compile all for errors if (xx == 60) { CompileAndAct(SearchFolders(@"..\Unity\User Games"), 0, 0, null); } Console.ReadLine(); } catch (PolyException ex) { _output.WriteLine(ex.Message); //} catch (Exception ex) { // _output.WriteLine($"Unexpected exception: {ex.ToString()}"); // return; } }
static void Main(string[] args) { Logger.Open(0); // no default logging _output = Logger.Out; // FIX:? Logger.WriteLine(Version); var options = OptionParser.Create(_options, _help); if (!options.Parse(args)) { return; } // trigger options here to avoid having to change debug conditions if (_xdebug) { //options.Parse(new string[] { @"..\UnityPlayer\Test Puzzles\ascripttest.txt", "/2", "/input=right" }); options.Parse(new string[] { "/33", "/input=right" }); //options.Parse(new string[] { @"..\UnityPlayer\Puzzles\new\2048.txt", "/2", "/input=level 3,left" }); //options.Parse(new string[] { @"..\UnityPlayer\puzzles\New\333.txt", "/2", "/input=tick" }); //options.Parse(new string[] { @"..\UnityPlayer\puzzles\New\fifteen.txt", "/2", "/input=fire1 28" }); //options.Parse(new string[] { @".\demo\threes.txt", "/0", "/input=up,down,left,right", "/endl" }); //options.Parse(new string[] { "/jta", "testdata.json", "/f=collapse simple", "/0" }); //options.Parse(new string[] { "/3" }); //options.Parse(new string[] { @"..\UnityPlayer\\Assets\Resources\Puzzles\yasban.txt", "/2", }); //options.Parse(new string[] { @"..\UnityPlayer\Test Puzzles\Buggy\threes.txt", "/3", }); //options.Parse(new string[] { @"..\UnityPlayer\Puzzles\new\colour wheel.txt", "/3", }); //options.Parse(new string[] { @"..\UnityPlayer\Puzzles\new\loops_of_zen.txt", "/3", "/level=1", "/input=init" }); //options.Parse(new string[] { @".\jsonconvert\085-Sok7.txt", "/2" }); //options.Parse(new string[] { "/3", "/input=action,right,right,left,right" }); //options.Parse(new string[] { @".\test puzzles\basicloop.txt", "/502", "/input=right" }); //options.Parse(new string[] { @".\test puzzles\rigid.txt", "/502", "/input=right,right,right,down,right" }); //options.Parse(new string[] { @".\test puzzles\laserblock.txt", "/3", "/input=right" }); //options.Parse(new string[] { @"..\UnityPlayer\Assets\Resources\New Puzzles\loops_of_zen.txt", "/3", "/input=fire1 12" }); //options.Parse(new string[] { @".\test puzzles\input_click.txt", "/503", "/input=hover 2" }); //options.Parse(new string[] { @"..\UnityPlayer\test puzzles\New\loops_of_zen.txt", "/3", "/input=fire1 12" }); //options.Parse(new string[] { @".\test puzzles\ellipsisnodup.txt", "/403", "/input=right", "/endl" }); //options.Parse(new string[] { @".\jsonconvert\117-Rigidbody fix bug #246.txt", "/201", "/input=up,up" }); //options.Parse(new string[] { "/jct", "/0" }); //options.Parse(new string[] { @".\demo\collapse.txt", "/403", "/lev=3", "/input=up,right,right,right" }); //options.Parse(new string[] { @".\test puzzles\ellipsisdrag.txt", "/403", "/input=right", "/endl" }); //options.Parse(new string[] { @".\test puzzles\ellipsisfill.txt", "/403", "/input=right", "/endl" }); //options.Parse(new string[] { @".\demo\tiny treasure hunt.txt", "/2", "/input=action,action,action", "/endl" }); //options.Parse(new string[] { @".\demo\microban.txt", "/2", "/input=action,action,action", "/endl" }); //options.Parse(new string[] { @".\demo\dropswap.txt", "/2", "/input=action,action,action", "/endl" }); //options.Parse(new string[] { @"randwater.txt", "/2", "/input=left", "/tim" }); //options.Parse(new string[] { @"rose.txt", "/1", "/input=action", "/tim" }); //options.Parse(new string[] { @".\demo\byyourside.txt", "/2", "/input=action", "/endl" }); //options.Parse(new string[] { @".\demo\atlas shrank.txt", "/2", "/input=action", "/endl" }); //options.Parse(new string[] { @".\gistrename\vertebrae.txt", "/2", "/input=action,tick,input=action,tick" }); //options.Parse(new string[] { @".\gistrename\watch your step.txt", "/2", "/input=action,tick,input=action,tick" }); //options.Parse(new string[] { "/gcon", "/2" }); //options.Parse(new string[] { "/gist", "/2" }); //options.Parse(new string[] { @".\demo\cratopia.txt", "/301", "/input=action,action,right,left" }); //options.Parse(new string[] { @".\demo\whaleworld.txt", "/301", "/input=action,up" }); //options.Parse(new string[] { "/jta", "testdata.json", "/f=by your side", "/0" }); //options.Parse(new string[] { "/302", "/input=right,right,right,right" }); //options.Parse(new string[] { "/jta", "testdata.json", "/f=drop swap", "/0" }); //options.Parse(new string[] { "/deb", "/input=right,right" }); //options.Parse(new string[] { "/jta", "testdata.json", "/f=whale", "/0" }); //options.Parse(new string[] { "SimpleBlockPushing.txt", "/301", "/input=action,right" }); //options.Parse(new string[] { "/jts", "testcase.json", "/3" }); //Logger.Level = 301; //_inputs = "right,right"; //_take = 1; //_jtarray = true; //_filter = "explod"; //_jsonarray = true; //_jsonsingle = true; //_xpath = "testcase.json"; //_gist = "0ebbe5e1f0761a87cc7aeace0d5e4b8e"; //_jsonconvert = true; //_dir = true; //path = "2048.txt"; //_encodelevel = true; //path = "../demo/modality.txt"; //path = "../demo/ebony and ivory.txt"; //path = "../demo/cute train.txt"; //path = "../demo/atlas shrank.txt"; } if (_jtarray) { foreach (var path in options.GetPathnames(_xpath ?? "testdata.json")) { RunJsonTests(path, ReadFile(path)); } } else if (_jtsingle) { foreach (var path in options.GetPathnames(_xpath ?? "testcase.json") .Where(p => p.ToLower().Contains(_filter))) { RunJsonTestCase(path, ReadFile(path)); } } else if (_jconvert != null) { foreach (var path in options.GetPathnames(_xpath ?? "testdata.json") .Where(p => p.ToLower().Contains(_filter))) { RunJsonConvert(path, ReadFile(path), _jconvert); } } else if (_jctest != null) { foreach (var file in options.GetPathnames(_xpath ?? "jsonconvert") .Where(p => p.ToLower().Contains(_filter))) { RunJsonConvTest(file); } } else if (_gist != null) { RunGist(_gist); } else if (_urllink != null) { RunUrlLink(_urllink); } else if (_urlquery != null) { RunUrlQuery(_urlquery); } else if (_gconvert != null) { foreach (var filename in options.GetPathnames(_xpath ?? "gists.txt") .Where(p => p.ToLower().Contains(_filter))) { RunGistConvert(filename, _gconvert); } //--- static test data cases ----------------------------------------------- } else if (_static) { //if (_xdebug) _filter = "PRBG"; _output.WriteLine($"Compiling test case: '{_filter}'"); var testcase = StaticTestData.GetTestCase(_filter, "PRBG with winco", "(win):@(rul):[>p|r]->[>p|>r]"); RunScript(_filter, testcase.Script, _inputs, _startlevel); //--- default script ----------------------------------------------- } else { var defaultscript = "testgame.txt"; //if (_xdebug) Logger.Level = 202; //if (_xdebug) _inputs = "right,right,right,down,right"; //if (_xdebug) _inputs = "left,left"; //if (_xdebug) _inputs = "right,right"; //if (_xdebug) defaultscript = "SimpleBlockPushing.txt"; foreach (var path in options.GetPathnames(defaultscript)) //()) { RunScript(path, ReadFile(path), _inputs, _startlevel); } } }
static void Main(string[] args) { Logger.Open(1); _output = Console.Out; _output.WriteLine(AndlVersion); var options = OptionParser.Create(_options, Help); if (!options.Parse(args)) { return; } var path = options.GetPath(0) ?? "test.andl"; var database = options.GetPath(1) ?? "db"; try { if (!File.Exists(path)) { throw ProgramError.Fatal($"file does not exist: {path}"); } var input = new StreamReader(path).ReadToEnd(); var conn = ConnectionInfo.Create("localhost", "postgres", database); var pgw = WrapLibpq.Create(conn, _output); // use npgsql instead //var conn = ConnectionInfo.Create("localhost", "admin", "zzxx", "Try1"); //var pgw = WrapNpgsql.Create(conn); var bp = new Boilerplate(); if (_usepreamble) { pgw.RunSql(bp.Preamble(), "preamble"); } switch (Path.GetExtension(path)) { case ".andl": pgw.Compile(input, path); break; case ".sql": case ".pgs": case ".pgsql": pgw.RunSql(input, path); break; default: throw ProgramError.Fatal($"no action defined for {path}"); } if (_usepostamble) { pgw.RunSql(bp.Postamble(), "postamble"); } pgw.Close(); } catch (ProgramException ex) { _output.WriteLine(ex.Message); return; } catch (Exception ex) { _output.WriteLine($"Unexpected exception: {ex.ToString()}"); return; } }