From 3b4b4983beb5737d506df00943f1d51ff274548e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Fri, 28 Jan 2022 12:34:47 +0100 Subject: [PATCH 1/2] Put new crontab in release path --- src/task/cron.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/task/cron.php b/src/task/cron.php index d0b0f69..77dbd83 100644 --- a/src/task/cron.php +++ b/src/task/cron.php @@ -10,7 +10,6 @@ use function Deployer\run; use function Deployer\set; use function Deployer\task; -use function Deployer\test; use function Deployer\upload; use function Deployer\writeln; use function file_put_contents; @@ -98,24 +97,13 @@ upload('new_crontab.txt', 'new_crontab.txt'); if (get('cron_dry_run') === false) { - run(sprintf('cat new_crontab.txt | crontab%s -', $cronUser !== '' ? (' -u ' . $cronUser) : '')); + run(sprintf('cat {{release_path}}/new_crontab.txt | crontab%s -', $cronUser !== '' ? (' -u ' . $cronUser) : '')); } })->desc('Builds and applies new crontab'); task('cron:cleanup', static function (): void { - if (file_exists('existing_crontab.txt')) { - @unlink('existing_crontab.txt'); - } - + // delete local file if (file_exists('new_crontab.txt')) { @unlink('new_crontab.txt'); } - - if (test('[ -f existing_crontab.txt ]')) { - run('rm existing_crontab.txt'); - } - - if (test('[ -f new_crontab.txt ]')) { - run('rm new_crontab.txt'); - } })->desc('Removes any generated files'); From 93412f5fc2230f3986442832ded6335292f230e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Fri, 28 Jan 2022 12:36:31 +0100 Subject: [PATCH 2/2] Missing release path in upload destination --- src/task/cron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/task/cron.php b/src/task/cron.php index 77dbd83..ca4e2d6 100644 --- a/src/task/cron.php +++ b/src/task/cron.php @@ -94,7 +94,7 @@ writeln($newCrontab, OutputInterface::VERBOSITY_VERBOSE); file_put_contents('new_crontab.txt', $newCrontab); - upload('new_crontab.txt', 'new_crontab.txt'); + upload('new_crontab.txt', '{{release_path}}/new_crontab.txt'); if (get('cron_dry_run') === false) { run(sprintf('cat {{release_path}}/new_crontab.txt | crontab%s -', $cronUser !== '' ? (' -u ' . $cronUser) : ''));