Esempio n. 1
0
        private void RestartService()
        {
            string cmd = this.Config.GetValue <string>("RestartCommand");
            var    msg = RunnerModule.RunProcessAndGetMessage(cmd, timeout: 10000);

            this.Logger.LogInformation("Restart TinyProxy:" + msg);
        }
Esempio n. 2
0
 /// <summary>
 /// 运行一个程序并且等待程序结束获得打印数据
 /// </summary>
 /// <param name="program"></param>
 /// <param name="arguments"></param>
 /// <returns></returns>
 public static string RunProcessAndGetMessage(string program, string arguments)
 {
     try
     {
         RunnerModule p = new RunnerModule(program, arguments);
         return(p.RunAndWaitReturn());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Esempio n. 3
0
 private void StartProcess(string filePath, Action callback, string stems = "2stems")
 {
     Console.WriteLine("Spleeter start!");
     this.runner = new RunnerModule("miniconda3/Scripts/activate.bat", $"./miniconda3 && python -m spleeter separate -i \"{filePath}\" -p spleeter:{stems} -o output", false);
     this.runner.OnMessageReceive = (string msg) => {
         Console.WriteLine(msg);
     };
     this.runner.OnProcessExit = () =>
     {
         Console.WriteLine("Spleeter exited");
         callback();
     };
     this.runner.Run();
 }
Esempio n. 4
0
 private void RedialNode()
 {
     while (true)
     {
         try
         {
             this.Logger.LogInformation("Try Redial......");
             string cmd = this.Config.GetValue <string>("RedialCommand");
             var    msg = RunnerModule.RunProcessAndGetMessage(cmd, timeout: 10000);
             this.Logger.LogInformation("Redial VPS:" + msg);
             this.Http = new HttpClient();
             this.Http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36");
             this.Http.DefaultRequestHeaders.Add("Accept", "*/*");
             this.TryGetIp();
             break;
         }
         catch
         {
             this.Logger.LogWarning("Redial Failure,Retrying...");
             Thread.Sleep(5000);
         }
     }
 }