Skip to content

Commit

Permalink
Merge branch 'dev' into 0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 5, 2018
2 parents 83aa12f + f598a4e commit 029d943
Show file tree
Hide file tree
Showing 19 changed files with 698 additions and 393 deletions.
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
2018-09-05 DariusIII
* Chg: Remove now unused packages folder
* Chg: Add beyondcode/laravel-dump-server to dev requirements
* Chg: Update used libraries to their latest versions
2018-09-04 DariusIII
* Fix: Return error message on missing parameters for failed releases
* Fix: Add check for empty sharing table when running tmux
2018-09-03 DariusIII
* Fix: Fix monitor counts and percentages displayed in main monitor pane
Expand Down
47 changes: 21 additions & 26 deletions app/Console/Commands/TmuxUIStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace App\Console\Commands;

use Blacklight\Tmux;
use App\Models\Settings;
use Blacklight\ColorCLI;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class TmuxUIStart extends Command
{
Expand All @@ -19,36 +21,29 @@ class TmuxUIStart extends Command
*
* @var string
*/
protected $description = 'Start the processing of tmux scripts. This is functionally equivalent to setting the
\'tmux running\' setting in admin.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
protected $description = 'Start the processing of tmux scripts.';

/**
* Execute the console command.
*
* @return mixed
* @throws \Symfony\Component\Process\Exception\LogicException
* @throws \Symfony\Component\Process\Exception\RuntimeException
*/
public function handle()
{
$process = new Process('php misc/update/tmux/start.php');
$process->setTty(Process::isTtySupported());
$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
} else {
echo $buffer;
}
});
$tmux = new Tmux();
$tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0;

// Set running value to on.
$tmux->startRunning();

// Create a placeholder session so tmux commands do not throw server not found errors.
exec('tmux new-session -ds placeholder 2>/dev/null');

//check if session exists
$session = shell_exec("tmux list-session | grep $tmux_session");
// Kill the placeholder
exec('tmux kill-session -t placeholder');
if ($session === null) {
ColorCLI::doEcho(ColorCLI::info('Starting the tmux server and monitor script.'), true);
passthru('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/update/tmux/run.php');
}
}
}
41 changes: 8 additions & 33 deletions app/Console/Commands/TmuxUIStop.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Console\Commands;

use Blacklight\Tmux;
use App\Models\Settings;
use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
Expand All @@ -20,50 +21,24 @@ class TmuxUIStop extends Command
*
* @var string
*/
protected $description = 'Stop the processing of tmux scripts. This is functionally equivalent to unsetting the
\'tmux running\' setting in admin. Usage: tmux-ui:stop false (does not kill tmux session), while using true will kill current tmux session';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
protected $description = 'Stop the processing of tmux scripts.';

/**
* @throws \Exception
*/
public function handle()
{
if ($this->argument('type') === 'false' || $this->argument('type') === 'true') {
$process = new Process('php misc/update/tmux/stop.php');
$process->setTimeout(600);
$process->run(
function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
} else {
echo $buffer;
}
}
);
if ($this->argument('type') !== null) {
(new Tmux())->stopIfRunning();

if ($this->argument('type') === 'true') {
$sessionName = Settings::settingValue('site.tmux.tmux_session');
$tmuxSession = new Process('tmux kill-session -t '.$sessionName);
$this->info('Killing active tmux session: '.$sessionName);
$tmuxSession->run(
function ($type, $buffer) {
if (Process::ERR === $type) {
echo 'ERR > '.$buffer;
} else {
echo $buffer;
}
}
);
$tmuxSession->run();
if ($tmuxSession->isSuccessful()) {
$this->info('Tmux session killed successfully');
}
}
} else {
$this->error($this->description);
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/FailedReleasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ public function show(Request $request)

return response('Success', 200)->withHeaders(['Location' => $this->serverurl.'getnzb?id='.$alt['guid'].'&i='.$uid.'&r='.$rssToken]);
}

return response('Error!', 400)->withHeaders(['X-DNZB-RCode' => 400, 'X-DNZB-RText' => 'Bad request, please supply all parameters!']);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
"fideloper/proxy": "~4.0",
"foolz/sphinxql-query-builder": "^1.2",
"fxp/composer-asset-plugin": "~1.1",
"genealabs/laravel-caffeine": "^0.6.11",
"geoip2/geoip2": "^2.9",
"google/recaptcha": "~1.1",
"guzzlehttp/guzzle": "^6.3",
Expand Down Expand Up @@ -172,6 +171,7 @@
},

"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"barryvdh/laravel-debugbar": "^3.1",
"barryvdh/laravel-ide-helper": "^2.4",
"filp/whoops": "~2.0",
Expand Down
Loading

0 comments on commit 029d943

Please sign in to comment.