-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (45 loc) · 1.23 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Net;
using System.Text;
using Fardin;
using Mahi.Properties;
using Mahi.Core;
using Mahi.Settings;
namespace Mahi
{
internal class Program
{
const string ip = "127.0.0.1";
const int port = 1010;
static readonly Logger logger = new Logger();
static void Main()
{
Console.Title = "Mahi 1.0";
// true means that created a template successfully
if (Templates.Template.CreateFromArguments())
return;
// load settings
AppConfig.LoadConfigs();
// watch appconfig.yaml
AppConfig.StartConfigWatcher();
// start server
//var server = new HttpServer(IPAddress.Parse(ip), port, "cert.pfx", Resources.CertificationPassword);
var server = new HttpServer(IPAddress.Parse(ip), port);
server.BaseDirectory = AppConfig.Instance.BaseDirectory;
try
{
server.Start();
}
catch (Exception ex)
{
logger.Log("&c" + ex.ToString());
return;
}
logger.Log("[&2Info&r] &fStarting server ...");
logger.Log($"[&2Info&r] &fServer started and binded on &7http{(server.IsTlsSecure ? "s" : "")}://{ip}:{port}/");
RequestHandler.Process(server);
logger.Dispose();
}
internal static void Log(string message, bool newLine = true)
=> logger.Log(message, newLine);
}
}