Select Git revision
SickBeard.py
Program.cs 9.19 KiB
using CommandLine;
using Jackett.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
/*
// no supported by appveyor, disabeling for now
#if __MonoCS__
using Mono.Unix.Native;
#endif
*/
namespace Jackett.Updater
{
class Program
{
static void Main(string[] args)
{
new Program().Run(args);
}
private void Run(string[] args)
{
Engine.SetupLogging(null, "updater.txt");
Engine.Logger.Info("Jackett Updater v" + GetCurrentVersion());
Engine.Logger.Info("Options \"" + string.Join("\" \"", args) + "\"");
try {
var options = new UpdaterConsoleOptions();
if (Parser.Default.ParseArguments(args, options))
{
ProcessUpdate(options);
}
else
{
Engine.Logger.Error("Failed to process update arguments!");
Console.ReadKey();
}
}
catch (Exception e)
{
Engine.Logger.Error(e, "Exception applying update!");
}
}
private string GetCurrentVersion()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
return fvi.FileVersion;
}
private void KillPids(int[] pids)
{
foreach (var pid in pids)
{
try
{
var proc = Process.GetProcessById(pid);
Engine.Logger.Info("Killing process " + proc.Id);
proc.Kill();
var exited = proc.WaitForExit(5000);
if (!exited)
Engine.Logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds");