Skip to content
GitLab
Erkunden
Anmelden
Registrieren
Primärnavigation
Suchen oder aufrufen …
Projekt
Cron
Verwalten
Aktivität
Mitglieder
Labels
Planen
Tickets
5
Ticketübersichten
Meilensteine
Wiki
Code
Merge Requests
0
Repository
Branch
Commits
Tags
Repository-Diagramm
Revisionen vergleichen
Build
Pipelines
Aufgaben
Pipeline-Zeitpläne
Artefakte
Bereitstellung
Releases
Betreiben
Umgebungen
Überwachen
Vorfälle
Service-Desk
Analysieren
Wertschöpfungskettenanalyse
Mitwirkenden-Analyse
CI/CD-Analyse
Repository-Analysen
Hilfe
Hilfe
Support
GitLab-Dokumentation
GitLab-Pläne vergleichen
Community-Forum
Zu GitLab beitragen
Feedback geben
Tastenkürzel
?
Code-Schnipsel
Gruppen
Projekte
Show more breadcrumbs
QUIQQER
Cron
Commits
7749ec86
Commit
7749ec86
erstellt
vor 9 Jahren
von
Henning Leutz
Dateien durchsuchen
Optionen
Downloads
Patches
Einfaches Diff
Cron Console kann einzelne Crons per ID ausführen
Übergeordneter
3c6f60bd
No related branches found
Branches enthält Commit
No related tags found
Tags enthält Commit
Keine zugehörigen Merge Requests gefunden
Änderungen
1
Leerzeichenänderungen ausblenden
Inline
Nebeneinander
1 geänderte Datei
lib/QUI/Cron/Console.php
+70
-19
70 Ergänzungen, 19 Löschungen
lib/QUI/Cron/Console.php
wird angezeigt
mit
70 Ergänzungen
und
19 Löschungen
lib/QUI/Cron/Console.php
+
70
−
19
Zeige Datei @
7749ec86
...
...
@@ -6,13 +6,14 @@
namespace
QUI\Cron
;
use
QUI
;
/**
* Cron Console Manager
*
* @author www.namerobot.com (Henning Leutz)
*/
class
Console
extends
\QUI\System\Console\Tool
class
Console
extends
QUI\System\Console\Tool
{
/**
* Konstruktor
...
...
@@ -20,7 +21,7 @@ class Console extends \QUI\System\Console\Tool
public
function
__construct
()
{
$this
->
setName
(
'package:cron'
)
->
setDescription
(
'Cron Manager'
);
->
setDescription
(
'Cron Manager'
);
}
/**
...
...
@@ -30,25 +31,28 @@ class Console extends \QUI\System\Console\Tool
*/
public
function
execute
()
{
$run
=
$this
->
getArgument
(
'--run'
);
$list
=
$this
->
getArgument
(
'--list'
);
$run
=
$this
->
getArgument
(
'--run'
);
$list
=
$this
->
getArgument
(
'--list'
);
$listall
=
$this
->
getArgument
(
'--list-all'
);
$runCron
=
$this
->
getArgument
(
'--cron'
);
if
(
$run
)
{
$this
->
run
();
return
;
}
if
(
$list
)
{
$this
->
listCrons
();
return
;
}
if
(
$listall
)
{
$this
->
listAllCrons
();
return
;
}
if
(
$runCron
)
{
$this
->
runCron
(
$runCron
);
return
;
}
...
...
@@ -68,6 +72,7 @@ class Console extends \QUI\System\Console\Tool
$this
->
writeLn
(
"- run
\t\t
run all active crons"
);
$this
->
writeLn
(
"- list
\t\t
list all active crons"
);
$this
->
writeLn
(
"- list-all
\t
list all crons"
);
$this
->
writeLn
(
"- cron
\t
run a specific cron"
);
$this
->
writeLn
(
''
);
...
...
@@ -93,9 +98,27 @@ class Console extends \QUI\System\Console\Tool
$this
->
commandRead
();
break
;
case
'cron'
:
$this
->
write
(
"Please enter the Cron-ID: "
);
$cronId
=
$this
->
readInput
();
try
{
$this
->
runCron
(
$cronId
);
}
catch
(
QUI\Exception
$Exception
)
{
$this
->
writeLn
(
$Exception
->
getMessage
(),
'red'
);
$this
->
resetColor
();
$this
->
writeLn
(
''
);
}
$this
->
commandRead
();
break
;
default
:
$this
->
writeLn
(
'Command not found, please type another command'
,
'red'
);
$this
->
writeLn
(
'Command not found, please type another command'
,
'red'
);
$this
->
commandRead
();
}
}
...
...
@@ -122,7 +145,7 @@ class Console extends \QUI\System\Console\Tool
public
function
listCrons
()
{
$Manager
=
new
Manager
();
$list
=
$Manager
->
getList
();
$list
=
$Manager
->
getList
();
$this
->
writeLn
(
'Cron list:'
);
$this
->
writeLn
(
'======================================================='
);
...
...
@@ -133,12 +156,15 @@ class Console extends \QUI\System\Console\Tool
continue
;
}
$time
=
$entry
[
'min'
]
.
' '
.
$entry
[
'hour'
]
.
' '
.
$entry
[
'day'
]
.
' '
.
$entry
[
'month'
];
$time
=
$entry
[
'min'
]
.
' '
.
$entry
[
'hour'
]
.
' '
.
$entry
[
'day'
]
.
' '
.
$entry
[
'month'
];
$exec
=
$entry
[
'exec'
];
$this
->
writeLn
(
'ID: '
.
$entry
[
'id'
]);
$this
->
writeLn
(
$time
.
"
\t
"
.
$exec
,
'green'
);
$this
->
writeLn
(
'ID: '
.
$entry
[
'id'
]);
$this
->
writeLn
(
$time
.
"
\t
"
.
$exec
,
'green'
);
$this
->
resetColor
();
$this
->
writeLn
(
''
);
...
...
@@ -154,19 +180,22 @@ class Console extends \QUI\System\Console\Tool
public
function
listAllCrons
()
{
$Manager
=
new
Manager
();
$list
=
$Manager
->
getList
();
$list
=
$Manager
->
getList
();
$this
->
writeLn
(
'Cron list:'
);
$this
->
writeLn
(
'======================================================='
);
$this
->
writeLn
(
''
);
foreach
(
$list
as
$entry
)
{
$time
=
$entry
[
'min'
]
.
' '
.
$entry
[
'hour'
]
.
' '
.
$entry
[
'day'
]
.
' '
.
$entry
[
'month'
];
$time
=
$entry
[
'min'
]
.
' '
.
$entry
[
'hour'
]
.
' '
.
$entry
[
'day'
]
.
' '
.
$entry
[
'month'
];
$exec
=
$entry
[
'exec'
];
$this
->
writeLn
(
'ID: '
.
$entry
[
'id'
]);
$this
->
writeLn
(
$time
.
"
\t
"
.
$exec
,
'green'
);
$this
->
writeLn
(
'ID: '
.
$entry
[
'id'
]);
$this
->
writeLn
(
$time
.
"
\t
"
.
$exec
,
'green'
);
$this
->
resetColor
();
$this
->
writeLn
(
''
);
...
...
@@ -175,4 +204,26 @@ class Console extends \QUI\System\Console\Tool
$this
->
writeLn
(
'======================================================='
);
$this
->
writeLn
(
''
);
}
/**
* Run a specific cron
*
* @param Boolean|Integer $cronId - ID of the cron
* @throws QUI\Exception
*/
public
function
runCron
(
$cronId
=
false
)
{
$Manager
=
new
Manager
();
$cron
=
$Manager
->
getCronById
(
$cronId
);
if
(
!
$cron
)
{
throw
new
QUI\Exception
(
'Cron not found'
);
}
$this
->
writeLn
(
'Execute Cron: '
.
$cronId
.
' '
.
$cron
[
'title'
]);
$Manager
->
executeCron
(
$cronId
);
$this
->
writeLn
(
'======================================================='
);
$this
->
writeLn
(
''
);
}
}
This diff is collapsed.
Zum Erweitern klicken.
Vorschau
0%
Wiederholen
oder
Neue Datei anhängen
.
Abbrechen
You are about to add
0
people
to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Kommentar speichern
Abbrechen
Bitte
registrieren
oder
Anmelden
zum Kommentieren