|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using UptimeKuma.Properties;
|
|
|
|
using UptimeKuma.Properties;
|
|
|
@ -14,7 +15,7 @@ namespace UptimeKuma {
|
|
|
|
/// The main entry point for the application.
|
|
|
|
/// The main entry point for the application.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
[STAThread]
|
|
|
|
[STAThread]
|
|
|
|
static void Main() {
|
|
|
|
static void Main(string[] args) {
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
Application.Run(new UptimeKumaApplicationContext());
|
|
|
|
Application.Run(new UptimeKumaApplicationContext());
|
|
|
@ -28,37 +29,44 @@ namespace UptimeKuma {
|
|
|
|
|
|
|
|
|
|
|
|
public UptimeKumaApplicationContext()
|
|
|
|
public UptimeKumaApplicationContext()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Initialize Tray Icon
|
|
|
|
|
|
|
|
trayIcon = new NotifyIcon();
|
|
|
|
trayIcon = new NotifyIcon();
|
|
|
|
|
|
|
|
|
|
|
|
trayIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
|
|
|
|
trayIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
|
|
|
|
trayIcon.ContextMenu = new ContextMenu(new MenuItem[] {
|
|
|
|
trayIcon.ContextMenu = new ContextMenu(new MenuItem[] {
|
|
|
|
new MenuItem("Open", Open),
|
|
|
|
new("Open", Open),
|
|
|
|
new MenuItem("Check for Update", CheckForUpdate),
|
|
|
|
//new("Debug Console", DebugConsole),
|
|
|
|
new MenuItem("About", About),
|
|
|
|
new("Check for Update...", CheckForUpdate),
|
|
|
|
new MenuItem("Exit", Exit),
|
|
|
|
new("Visit GitHub...", VisitGitHub),
|
|
|
|
|
|
|
|
new("About", About),
|
|
|
|
|
|
|
|
new("Exit", Exit),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trayIcon.MouseDoubleClick += new MouseEventHandler(Open);
|
|
|
|
|
|
|
|
|
|
|
|
trayIcon.Visible = true;
|
|
|
|
trayIcon.Visible = true;
|
|
|
|
|
|
|
|
|
|
|
|
var startInfo = new ProcessStartInfo();
|
|
|
|
var startInfo = new ProcessStartInfo {
|
|
|
|
startInfo.FileName = "node/node.exe";
|
|
|
|
FileName = "node/node.exe",
|
|
|
|
startInfo.Arguments = "server/server.js";
|
|
|
|
Arguments = "server/server.js --data-dir=\"../data/\"",
|
|
|
|
startInfo.RedirectStandardOutput = true;
|
|
|
|
RedirectStandardOutput = false,
|
|
|
|
startInfo.RedirectStandardError = true;
|
|
|
|
RedirectStandardError = false,
|
|
|
|
startInfo.UseShellExecute = false;
|
|
|
|
UseShellExecute = false,
|
|
|
|
startInfo.CreateNoWindow = true;
|
|
|
|
CreateNoWindow = true,
|
|
|
|
startInfo.WorkingDirectory = "core";
|
|
|
|
WorkingDirectory = "core"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
process = new Process();
|
|
|
|
process = new Process();
|
|
|
|
process.StartInfo = startInfo;
|
|
|
|
process.StartInfo = startInfo;
|
|
|
|
process.EnableRaisingEvents = true;
|
|
|
|
process.EnableRaisingEvents = true;
|
|
|
|
|
|
|
|
process.Exited += new EventHandler(ProcessExited);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
process.Start();
|
|
|
|
process.Start();
|
|
|
|
Open(null, null);
|
|
|
|
//Open(null, null);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
MessageBox.Show("Startup failed: " + e.Message, "Uptime Kuma Error");
|
|
|
|
MessageBox.Show("Startup failed: " + e.Message, "Uptime Kuma Error");
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -66,8 +74,17 @@ namespace UptimeKuma {
|
|
|
|
Process.Start("http://localhost:3001");
|
|
|
|
Process.Start("http://localhost:3001");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DebugConsole(object sender, EventArgs e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckForUpdate(object sender, EventArgs e) {
|
|
|
|
void CheckForUpdate(object sender, EventArgs e) {
|
|
|
|
|
|
|
|
Process.Start("https://github.com/louislam/uptime-kuma/releases");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void VisitGitHub(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Process.Start("https://github.com/louislam/uptime-kuma");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void About(object sender, EventArgs e)
|
|
|
|
void About(object sender, EventArgs e)
|
|
|
@ -79,9 +96,25 @@ namespace UptimeKuma {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Hide tray icon, otherwise it will remain shown until user mouses over it
|
|
|
|
// Hide tray icon, otherwise it will remain shown until user mouses over it
|
|
|
|
trayIcon.Visible = false;
|
|
|
|
trayIcon.Visible = false;
|
|
|
|
process.Close();
|
|
|
|
process.Kill();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ProcessExited(object sender, EventArgs e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (process.ExitCode != 0) {
|
|
|
|
|
|
|
|
var line = "";
|
|
|
|
|
|
|
|
while (!process.StandardOutput.EndOfStream)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
line += process.StandardOutput.ReadLine();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Uptime Kuma exited unexpectedly. Exit code: " + process.ExitCode + " " + line);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trayIcon.Visible = false;
|
|
|
|
Application.Exit();
|
|
|
|
Application.Exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|