wip del err
This commit is contained in:
1 parent
812736ca9a
commit
9bcd4432c6
1210 files changed
-220941
No files matched your search
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class SupervisorMaker
|
||||
{
|
||||
public static $base = '';
|
||||
|
||||
public static $path = '';
|
||||
|
||||
public static function run($supervisor)
|
||||
{
|
||||
$supervisors = Supervisor::all();
|
||||
|
||||
$path = base_path().'/supervisor/nuh';
|
||||
|
||||
if (! is_dir($path)) {
|
||||
mkdir($path, 0777);
|
||||
}
|
||||
|
||||
$file = new Filesystem;
|
||||
$file->cleanDirectory($path);
|
||||
|
||||
foreach ($supervisors as $supervisor) {
|
||||
|
||||
$parts = [];
|
||||
$parts[] = 'p'.$supervisor->id;
|
||||
if (isset($supervisor->sport->name)) {
|
||||
$parts[] = self::fix_string($supervisor->sport->name);
|
||||
} else {
|
||||
$parts[] = 'all';
|
||||
}
|
||||
$parts[] = self::fix_string($supervisor->provider->name);
|
||||
if ($supervisor->name) {
|
||||
$parts[] = self::fix_string($supervisor->name);
|
||||
}
|
||||
|
||||
if ($supervisor->days_to) {
|
||||
$parts[] = 'day'.$supervisor->days_from;
|
||||
$parts[] = 'day'.$supervisor->days_to;
|
||||
}
|
||||
|
||||
$process = strtolower(implode('_', $parts));
|
||||
|
||||
$content = '[program:'.$process.']'.PHP_EOL;
|
||||
if ($supervisor->commandline_options != '') {
|
||||
$content .= 'command=/usr/bin/php '.base_path().'/artisan nuh '.$supervisor->id.' '.$supervisor->commandline_options.PHP_EOL;
|
||||
} else {
|
||||
$content .= 'command=/usr/bin/php '.base_path().'/artisan nuh '.$supervisor->id.PHP_EOL;
|
||||
}
|
||||
$content .= 'autostart=true'.PHP_EOL;
|
||||
$content .= 'autorestart=true'.PHP_EOL;
|
||||
|
||||
$file = $path.'/'.$process.'.ini';
|
||||
if ($supervisor->is_active && $supervisor->is_supervisor) {
|
||||
file_put_contents($file, $content);
|
||||
chmod($file, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
if (config('env.app_env') == 'production') {
|
||||
$exec = base_path().'/supervisor/super_update.sh';
|
||||
exec($exec, $out, $rcode);
|
||||
}
|
||||
|
||||
Notice::note('SUPERVISOR '.\count($supervisors).' PROCESSES UPDATED', 'b', 1);
|
||||
}
|
||||
|
||||
public static function fix_string($string)
|
||||
{
|
||||
$string = preg_replace("'\W'", '_', $string);
|
||||
|
||||
return strtolower($string);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user