Commit 1a8971c 1 parent 4e12ce0 commit 1a8971c Copy full SHA for 1a8971c
File tree 8 files changed +25
-27
lines changed
8 files changed +25
-27
lines changed Original file line number Diff line number Diff line change 1
1
vendor
2
2
cache
3
3
.idea
4
+ * .phar
Original file line number Diff line number Diff line change 8
8
use Trig \LaraCron \Exception \ExitCommandException ;
9
9
use Trig \LaraCron \ExitCodes ;
10
10
use Illuminate \Console \Scheduling \Schedule ;
11
+ use Illuminate \Container \Container ;
11
12
12
- $ configFile = realpath (__DIR__ . ' /.. /laracron.json ') ;
13
+ $ configFile = realpath (' . ' ) . ' /laracron.json ' ;
13
14
14
15
$ io = new OutputStyle (
15
16
new ArgvInput (),
19
20
try {
20
21
$ cronApp = new \Trig \LaraCron \CronApplication ($ configFile );
21
22
23
+ function base_path ($ path = null )
24
+ {
25
+ $ container = Container::getInstance ();
26
+ return $ container ->get ('config ' )['basePath ' ].($ path ? DIRECTORY_SEPARATOR .$ path : $ path );
27
+ }
28
+
22
29
$ cronApp ->booting (
23
30
function (\Trig \LaraCron \CronApplication $ app ) use ($ io ) {
24
31
if ('redis ' === ($ app ->get ('config ' )['cache.default ' ] ?? null ) && !class_exists ('Redis ' )) {
Original file line number Diff line number Diff line change 13
13
"autoload" : {
14
14
"psr-4" : {
15
15
"Trig\\ " : " src//"
16
- },
17
- "files" : [
18
- " src/functions.php"
19
- ]
16
+ }
20
17
},
21
18
"authors" : [
22
19
{
Original file line number Diff line number Diff line change 1
1
{
2
2
"scheduledJobs" : {
3
3
"everyMinute" : [
4
- " app/console list" ,
5
- " app/console"
4
+ " php --version"
6
5
],
7
- "*/10 * * * *" : [
8
- " echo '*/10 * * * *'"
6
+ "* * * * *" : [
9
7
]
10
8
},
11
-
12
- "log" : " php://stdout" ,
9
+ "log" : " cron.log" ,
13
10
"cache.default" : " file" ,
14
11
"cache.prefix" : " laracron" ,
15
12
"cache.stores.file" : {
Original file line number Diff line number Diff line change @@ -48,14 +48,16 @@ function ($path) use ($basePath) {
48
48
->ignoreDotFiles (true );
49
49
50
50
$ pharFile = $ basePath .'/laracron.phar ' ;
51
- $ stubFile = $ basePath .'/bin/laracron.php ' ;
51
+ if (file_exists ($ pharFile )) {
52
+ unlink ($ pharFile );
53
+ }
52
54
53
55
$ this ->output ->progressAdvance (1 );
54
56
$ phar = new \Phar ($ pharFile );
55
57
$ phar ->buildFromIterator ($ files ->getIterator (), $ basePath );
56
58
57
59
$ this ->output ->progressAdvance (1 );
58
- $ phar ->setStub ($ phar ->createDefaultStub ($ stubFile ));
60
+ $ phar ->setStub ($ phar ->createDefaultStub (' bin/laracron.php ' ));
59
61
$ this ->output ->writeln ("Build completed. Phar saved to <comment> {$ pharFile }</comment> " );
60
62
}
61
63
Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ public function handle()
16
16
$ config = $ this ->getLaravel ()->get ('config ' );
17
17
foreach ($ config ['scheduledJobs ' ] ?? [] as $ definition => $ commands ) {
18
18
foreach ($ commands as $ command ) {
19
- $ event = $ this ->schedule ->exec ($ command )
19
+ $ event = $ this ->schedule
20
+ ->exec ($ command )
20
21
->name ($ this ->getUniqueName ($ definition , $ command ))
21
- ->onOneServer ();
22
+ ->onOneServer ()
23
+ ->appendOutputTo ($ config ['log ' ]);
22
24
23
25
$ isCronDefinition = false !== strpos ($ definition , ' ' );
24
26
Original file line number Diff line number Diff line change @@ -476,7 +476,10 @@ private function getConfig(string $configFile): array
476
476
throw new ExitCommandException ('ERROR_CONFIG_JSON_ERROR ' , ExitCodes::ERROR_CONFIG_JSON_ERROR );
477
477
}
478
478
479
- $ config ['basePath ' ] = realpath (__DIR__ . '/../../ ' );
479
+ $ config ['basePath ' ] = realpath ('. ' );
480
+ if (isset ($ config ['cache.stores.file ' ]['path ' ])) {
481
+ $ config ['cache.stores.file ' ]['path ' ] = $ config ['basePath ' ].DIRECTORY_SEPARATOR .ltrim ($ config ['cache.stores.file ' ]['path ' ], '/ ' );
482
+ }
480
483
481
484
return $ config ;
482
485
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments