provider->name); $path = base_path().'/supervisor/'.strtolower($dirname); if (! is_dir($path)) { mkdir($path, 0777); } $sport = self::fix_string($supervisor->sport?->name) ?? 'all'; $process = 'p'.$supervisor->id.'_'.self::fix_string($supervisor->name).'_'.$sport; if ($supervisor->days_to) { $process .= '_'.$supervisor->days_from; $process .= '_'.$supervisor->days_to; } $content = '[program:'.$process.']'.PHP_EOL; $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_cron) { file_put_contents($file, $content); chmod($file, 0777); } else { if (is_file($file)) { unlink($file); } } } 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); } }