Added sync ftp files command page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Successful in 3m31s
Laravel Larastan / larastan (pull_request) Failing after 5m2s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Successful in 3m31s
Laravel Larastan / larastan (pull_request) Failing after 5m2s
This commit is contained in:
57
app/Console/Commands/SyncFtpFiles.php
Normal file
57
app/Console/Commands/SyncFtpFiles.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class SyncFtpFiles extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ftp:sync';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Sync FTP files from Windows FTP server';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$process = new Process([
|
||||
'/usr/bin/flock',
|
||||
'-n',
|
||||
'/tmp/rclone-ftp.lock',
|
||||
'/usr/bin/rclone',
|
||||
'copy',
|
||||
'windowsftp:/LaserQS4/',
|
||||
'/srv/pds.iotsignin.com/www/ftpdata',
|
||||
'--include',
|
||||
'*.txt',
|
||||
'--log-file=' . storage_path('logs/rclone-ftp.log'),
|
||||
'--log-level',
|
||||
'INFO',
|
||||
]);
|
||||
|
||||
$process->setTimeout(null);
|
||||
$process->run();
|
||||
|
||||
if (!$process->isSuccessful()) {
|
||||
$this->error($process->getErrorOutput());
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('FTP synchronization completed successfully.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user