Charrua

Charrua

Member Since 1 Year Ago

A Coruña

Owner at Charrua

Experience Points 4,430
Experience Level 1

570 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 18
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

17 Apr
4 days ago

Charrua left a reply on Trying To Get Related Models Between Date Ranges, Need Advice On Architecture

@FTIERSCH - You are right, I was thinking in the wrong way. Thank you very much for your help! Solved my issue

Charrua left a reply on Trying To Get Related Models Between Date Ranges, Need Advice On Architecture

@FTIERSCH - Thank you for your help, this is getting closer, the result of that implementation is getting me the members that have activity between the range

now()->subDays(15) > 'scan_date' > now()->subDays(8)

Remember I need those members that have no activity on that date range

Charrua started a new conversation Trying To Get Related Models Between Date Ranges, Need Advice On Architecture

Hello, I'm struggling with obtaining some related models on custom date ranges. This is a school app that manages members and attendances. Each Member has many Attendance, when the member comes to school, a new record on the attendance table is inserted.

I would like to get some inactivity information to send some emails, for example: -members who are inactive one week -members who are inactive two weeks -members who are inactive one month -members who are inactive two months

The problem is that those members that are inactive for example one month, are also inactive one week, so if I send an email to inactive members from one week, also other inactive members are going to get this email.

I can get those ranges mentioned earlier, for example:

//Member.php
public function oneWeekInactive(){
    $date = new Carbon;
    $start = $date->copy()->subDays(8);
    $end = $date->copy();
    return $this->hasMany('App\Attendance')->whereBetween('scan_date', array($start, $end));
}

In my controller the query for those members is:

$members_to_notify = \App\Member::withoutGlobalScope(SchoolScope::class)
    ->whereNotNull('email')
    ->doesntHave('oneWeekInactive')
    ->get();

So my first question is, do you think I need to redefine those ranges as: -members who are inactive ONLY one week -members who are inactive ONLY two weeks -members who are inactive ONLY one month -members who are inactive ONLY two months

If the redefine is correct, how do you think I can get members for the first range get members with more than one week inactive but not two week inactive I know I need to subtract those members in some way but I'm stuck.

16 Apr
5 days ago

Charrua left a reply on Laravel Relation Query Taking Too Much Time To Load

@STAUDENMEIR - Seems that adding an index the query time is as expected, I'll post results here. Thank you

Charrua left a reply on Laravel Relation Query Taking Too Much Time To Load

@MUNAZZIL - I'm sorry but this does not work, thank you anyway ;)

Charrua left a reply on Laravel Relation Query Taking Too Much Time To Load

@MUNAZZIL - This does the same, 8 seconds waiting...

Charrua left a reply on Laravel Relation Query Taking Too Much Time To Load

@STAUDENMEIR - ``` $members = \App\Member::withoutGlobalScope(SchoolScope::class) ->whereNotNull('email') ->when($to_school, function ($query, $to_school) { return $query->where('school_id', $this->communication->school_id); }) ->has('attendance') ->get();

Charrua started a new conversation Laravel Relations Taking Too Much Time

Hello, I have two models, one for school Member and the other for school Attendance, each one with the corresponding database table.

My goal is to get all school members who have at least one attendance between some particular date, as an example let's take '2019-04-05' and '2019-04-12' (one week)

So in my Members model I have a relation:

public function attendance() {
    return $this->hasMany('App\Attendance')
->whereBetween('scan_date', array('2019-04-05', '2019-04-12'));
}

The problem is that the attendance table has like 76000 records now so the query takes about 8 seconds to get the results. Is there a way to make this query faster? maybe limit in some way?

09 Apr
1 week ago

Charrua started a new conversation Passing Laravel To Vue Collection Interpreted Different As Object And Array

Hello, I'm passing data to Vue from Laravel. I have a blade template and a Vue component that accept data on properties as:

<cash-sale-online-order-new
     :products="{{ $products }}">
</cash-sale-online-order-new>

Those products came from eloquent on a Laravel controller:

public function create(Request $request)
    {   
        
        $products = \App\Product::with(['product_type'])->get();

        return view('.....', compact('products'));
    }

This will give me an array of objects on Vue, and that is OK.

The problem is that when I $products = \App\Product::with(['product_type'])->get()->keyBy('id'); that collection, the result in Vue is an Object with Objects inside.

This is strange because if I inspect on Laravel with dd() both product queries (without keyBy('id') and with keyBy('id')) they both return a Collection and an Array inside, but for some reason they are differently seen by Vue.

Any ideas?

25 Mar
3 weeks ago

Charrua left a reply on Vue Child Component Is Updating Parent Data Without Event ?¿ Need Explanation

When assigning value to reference type, it will copy the pointer to the address. They point to the same memory address. ´´´ var obj1 = {a: 1} var obj2 = obj1 // copy the pointer to the address obj2 = {a: 2} // change obj2's value console.log(a) // {a: 2} console.log(b) = // {a: 2}

>if we assign a’s value to b and change b’s value will change a’s value.
They point to the same memory address.

>When we pass something to component, if it’s premitive type like “String”, “Number” and you change it’s value in component. Vue will trigger the checking function to let us know that we are changing the porps value. If it’s reference type like “Object” and you change it’s value in component. Vue will not trigger the checking function. Parent and child will share the value, point to the same address. They will change at the same time.

Charrua left a reply on Vue Child Component Is Updating Parent Data Without Event ?¿ Need Explanation

The strange thing is that I don't get any warnings on the developer console. Still investigating this I would love to fully understand.

24 Mar
4 weeks ago

Charrua started a new conversation Vue Child Component Is Updating Parent Without Event ?¿ Need Explanation

Hello, I'm using Vue components to send data to a parent component that is a form, each field is a child component. So for the child components I emit events as v-on:change="$emit('date_selected', date)", then I update the parent data by listening to those events.

The problem now is that I have some field that is updating parent without emitting any event, maybe is emitting something I can't see under the hood.

Parent component

<template>
    <div>
        <article-fields
            :products="products" 
            :items="items">
        </article-fields>    
        <a href="#" class="btn btn-sm btn-primary" v-on:click.stop.prevent="addArticle()">Add article</a>
    </div>         
</template>

<script>

    import articleFields from './form/articleFields';

    export default {

        components: {
            'article-fields': articleFields
        },
        props: {
            products: {
               type: Object,
               required: true,
            }
        },
        data () {
            return {
                items:[{product:{}, id:0, quantity:0, discount:0}],
            }
        },
        methods: {
            addArticle: function () {
                this.items.push( {product:{}, id:0, quantity:0, discount:0} )
            }
        }

    }
</script>

Child component

<template>   
    <div>
        <div v-for="(articulo, index) in items" v-bind:key="index">
            
            <select v-model="articulo.id" @change="assignProduct(articulo)">
                <option value="" disabled>Select...</option>
                <option v-for="(product) in products" :value="product.id" v-bind:key="product.id">
                    {{ product.name }} 
                </option>
            </select>

            <input v-model.number="articulo.product.price" type="text">
                           
            <input v-model.number="articulo.quantity" type="text">
                
            <input v-model.number="articulo.discount" type="text">
                
        </div>
    </div>        
</template>

<script>
    export default {
        inject: ['$validator'],
        props: {
            products: {
               type: Object,
            },
            items: {
               type: Array,
            }
        },
        methods: {
            assignProduct(item) {
                item.product = this.products[item.id]
            },
            removeArticle: function (index) {
                this.items.splice(index, 1)
            }
        }
    }
</script>

For some reason when I update the fields on child component, the items also get updated on parent. Anyone knows why this is happening?

05 Mar
1 month ago

Charrua left a reply on PUT Request From Axios => "405 Method Not Allowed"

Great, thank you all, issue solved!

04 Mar
1 month ago

Charrua left a reply on PUT Request From Axios => "405 Method Not Allowed"

Hello @sergiu17, all routes are registered as the controller is a resource controller, if I run php artisan route:list I get the following:

GET|HEAD   budgets   App\Http\Controllers\[email protected]
POST             budgets   App\Http\Controllers\[email protected]
GET|HEAD   budgets/create       App\Http\Controllers\[email protected]create
DELETE.        budgets/{budget}   App\Http\Controllers\[email protected]
PUT|PATCH budgets/{budget}.  App\Http\Controllers\[email protected]
GET|HEAD   App\Http\Controllers\[email protected]
GET|HEAD.  App\Http\Controllers\[email protected]

My controllers update method is:

public function update(Request $request, $id)
    {
        //
    }

Charrua started a new conversation PUT Request From Axios => "405 Method Not Allowed"

Hi, I'm using Axios in a Laravel + Vue app. I have my resource controller and trying to update some model, so I'm sending a PUT request, but with no success.

I get 405 Method Not Allowed using this code:

axios.put('http://127.0.0.1:8000/budgets', {
        date: this.date,
        items: this.items,
        notes: this.notes,
        sub_total: this.subTotal,
        tax: this.tax,
        total: this.total,
})
.then(function (response) {
        console.log(response)
})
.catch(function (error) {
        console.log(error.response.data)
                           
})

I have also tried to use

axios.post('http://127.0.0.1:8000/budgets', {
    _method: 'PUT',
        date: this.date,
        items: this.items,
        notes: this.notes,
        sub_total: this.subTotal,
        tax: this.tax,
        total: this.total,
})
.then(function (response) {
        console.log(response)
})
.catch(function (error) {
        console.log(error.response.data)
                           
})

But no success, any ideas on how to solve this issue?

16 Feb
2 months ago

Charrua left a reply on Trying To Load Selected Value On Select

Hello Tray, sorry but your solution does't work.

Charrua started a new conversation Trying To Load Selected Value On Select

Hello I have an issue loading the selected option of a select input. Here is my code, items is the object I want to populate with the products object

<div class="form-row" v-for="(article, index) in items" v-bind:key="index">
    <label class="form-control-label" for="input-name">Producto</label>
    <select name="articulo" v-model="article.product" v-validate="'required'" class="form-control">
        <option v-for="(product) in products" :value="product">
            {{ product.name }} 
        </option>
    </select>
</div>

If I run this code I get the product object inside each item object as expected. The problem is the reverse situation, if start the items object populated on page load, the selected option is not selected.

I have found a way for the select to work and is to change the value of the option, instead to use the product object, use a property as product.name and the same on the select model article.product.name. The issue is that I need the value of each option to populate the item.product object.

04 Dec
4 months ago

Charrua started a new conversation Vue-router And Vue-stripe-elements-plus Issue

Hi, I'm building a SPA with Vue, two pages are using the <Card> component from vue-stripe-elements-plus.

The views that load the <Card> component are /gala and /seminars.

The problem is when I change from one view to the other, the <Card> component seems not to render again and an error is shown in console:

vue.runtime.esm.js?2b0e:587 [Vue warn]: Error in beforeMount hook: "IntegrationError: Can only create one Element of type card."

My routes are:

import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home
    },
    {
      path: '/gala',
      name: 'gala',
      component: () => import(/* webpackChunkName: "about" */ './views/Gala.vue')
    },
    {
      path: '/seminars',
      name: 'seminars',
      component: () => import(/* webpackChunkName: "about" */ './views/Seminars.vue')
    }
  ]
})

Maybe I'm missing something?

29 Nov
4 months ago

Charrua left a reply on Which OAuth 2.0 Flow Should I Use? Vue Form And API

@D9705996 - That is what I’m looking for now, if I need to authenticate or not... how can I resolve this? Any more ideas? How to determine if I need authentication to send the form data or not...

Charrua left a reply on Which OAuth 2.0 Flow Should I Use? Vue Form And API

@D9705996 - Great answer, thank you. The ticket form will be public and reachable by all guest users (eg domain.com/form), they will not need to login to fill and send the form. And my API will live on anotherdomain.com/api

Maybe I'm confused and is not the case to use authenticated API requests to my app because there is no login on the frontend... I thought on using authenticated requests to add some security to my API but maybe is not the use case here.

Charrua started a new conversation Which OAuth 2.0 Flow Should I Use? Vue Form And API

Hello, I'm new to OAuth and APIs. I have set my Laravel API endpoints to store and send responses for saving a resource. In other webpage I have a Vue public form for users to buy tickets and store them in the Laravel app.

If I use passport, what type of authorization flow (why, benefits) I need to use to authenticate all requests to my API? Thank you.

13 Nov
5 months ago

Charrua left a reply on Laravel Storing Images Outside Public Directory

@talinon you are right, that solved my issue. Thank you.

Charrua started a new conversation Laravel Storing Images Outside Public Directory

Hello, I'm trying to store images using the local driver. I have followed docs and created the symbolic link php artisan storage:link

I'm saving a file from a form and in my controller I have the following: $communication->image = Storage::putFile('messages', $request->file('image'));

The problem is that this is creating a directory messages inside storage/app/messages and not in storage/app/public/messages as it should.

My ´config/filesystems.php` is:

return [

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    'cloud' => env('FILESYSTEM_CLOUD', 's3'),

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

    ],

];

Any ideas?

10 Nov
5 months ago

Charrua left a reply on Getting Error OuteNotificationFor() On Batch Email Notifications

This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.

09 Nov
5 months ago

Charrua started a new conversation Getting Error OuteNotificationFor() On Batch Email Notifications

Hello, I'm trying to send email to members on my app and I get the following error:

production.ERROR: Call to undefined method Illuminate\Database\Query\Builder::routeNotificationFor() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method Illuminate\Database\Query\Builder::routeNotificationFor() at /var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)

I have the members model with the Notifiable trait and the weird issue is that on my local machine the emails are delivered... The problem is on production... Any ideas?

The notifications are fired with:

Notification::send($members_to_notify, new CommMessage($communication));

And the CommMessageclass is:


namespace App\Notifications\Communications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

use App\Mail\Communications\Message as Mailable;

class CommMessage extends Notification implements ShouldQueue
{
    use Queueable;

    private $communication;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($communication)
    {
        $this->communication = $communication;
       
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return Mailable
     */
    public function toMail($notifiable)
    {
        return (new Mailable($this->communication))->to($notifiable->email);
    }
    
}

The mailable Message class is:

namespace App\Mail\Communications;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Message extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * The appointment instance.
     *
     * @var Appointment
     */
    public $communication;
    
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($communication)
    {
        $this->communication = $communication;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $this->replyTo($this->communication->school->email)->markdown('emails.communications.message');

        $this->subject($this->communication->title);

        $this->withSwiftMessage(function ($message) {
            $message->getHeaders()
                    ->addTextHeader('X-Mailgun-Variables', json_encode([
                        'model_id' => $this->communication->id,
                        'model' => get_class($this->communication),
                        'email_type' => 11 //Communication message (EmailLogType)
                    ]));
        });

    }

}
13 Oct
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

@hondnl this is the Plesk engineer answer:

This is a known issue with plesk-php7x which have libsodium package included for stronger cryptography.

Forced initialization of crypto library on startup each PHP script depletes entropy (/dev/random) and next processes wait for another portion of randomness. So any php script can cause entropy depletion.

The developers have submitted this issue as a bug PPPM-9444 which is planned to be fixed in one of the future Plesk updates.

Please subscribe to the following article to be notified when the bug is fixed: https://support.plesk.com/hc/en-us/articles/360010129094

11 Oct
6 months ago

Charrua started a new conversation Integrating Facebook Page_insights With Laravel

Hello, what would be a good workflow to integrate facebook page insights in a Laravel dashboard app?

I don't know where to start.

Any ideas would be great!

Charrua left a reply on Scheduler Running Strange

The issue was caused by depleted entropy by PHP script.

To resolve the issue generate entropy by using haveged daemon:

Enable EPEL repository: yum install epel-release

Install daemon with the following command and enable it: yum install haveged

chkconfig haveged on

systemctl start haveged

10 Oct
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

The issue was caused by depleted entropy by PHP script.

To resolve the issue generate entropy by using haveged daemon:

  1. Enable EPEL repository:

    yum install epel-release

  2. Install daemon with the following command and enable it:

    chkconfig haveged on
    systemctl start haveged```
    
03 Oct
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

@D9705996 Really strange news. I have talked with plesk support, an engineer logged in and he returns to me that "he cant reproduce the issue.

So I logged in and now even I can't reproduce the issue, apparently all is running on time. I have asked him if he changed anything but I'm still waiting for an answer. All crons are fired on time and tasks on time.

I have checked all logs and there is no accumulation or delay for tasks. Really strange but good (for now). Yesterday and all past days the server failed one time in 10 minutes average. Now it is running for about 5 hours without any issue.

02 Oct
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

the PHP5.4 is installed by OS vendor

5.4.16 by OS vendor FPM application

This is listed in plesk. Maybe I need to update the digital oceans php version to 7.1 instead of plesk...

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click Yes, Laravel needs PHP >= 7.0, so I can't run it only with php (I have tried to run scheduler but it shows an error)

php /var/www/vhosts/domain***/laravel/artisan schedule:run
PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/winnersmartialarts.com/laravel/artisan on line 33

I'm talking with the plesk support team so I let them finish their investigations and try to remove PHP 5.4 and make 7.1 the default and see what happens. Hope this solves the issue...

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click I think you have discovered some light...

If I run php -v the output is

PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.0.3, Copyright (c) 2002-2017, by ionCube Ltd.

So for my app I needed to use 7.1 so I searched and use /opt/plesk/php/7.1/bin/php so for example my cron's php path is /opt/plesk/php/7.1/bin/php /path/to/file.php and not php /path/to/file.php

Observation: 2 different versions here....

The light comes in when running watch -n1 php test.php or watch -n1 /opt/plesk/php/7.1/bin/php test.php

If I run the one with the php 7.1 path it hangs as cron do, but the other one does not hang...

While the system is lagged, seems that using php instead of /opt/plesk/php/7.1/bin/php keeps running. Hope this helps you to send some light to the solution

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click, yes that's what I'm thinking, something related with php/apache/nginx as you said. The app runs smooth via browser, even when the php scripts that came from cron are delayed, the app runs as usual...

Charrua left a reply on Scheduler Running With Delay (not On Time)

@shez1983 in the logs there is nothing related to what is happening. But I discovered something, someone else told me to create a bash script and test it with cron:

Bash script:

#!/bin/bash
echo $(date);
exit 0

Crontab:

* * * * * /var/www/vhosts/domain***/test.sh >> /var/www/vhosts/winnersmartialarts.com/logs/domain***/date.log

But the results surprised me, they are great:

Tue Oct 2 05:08:01 EDT 2018
Tue Oct 2 05:09:01 EDT 2018
Tue Oct 2 05:10:01 EDT 2018
Tue Oct 2 05:11:01 EDT 2018
Tue Oct 2 05:12:01 EDT 2018
Tue Oct 2 05:13:01 EDT 2018
Tue Oct 2 05:14:01 EDT 2018
Tue Oct 2 05:15:01 EDT 2018
Tue Oct 2 05:16:01 EDT 2018
Tue Oct 2 05:17:01 EDT 2018
Tue Oct 2 05:18:01 EDT 2018
Tue Oct 2 05:19:02 EDT 2018
Tue Oct 2 05:20:01 EDT 2018
Tue Oct 2 05:21:01 EDT 2018
Tue Oct 2 05:22:01 EDT 2018
Tue Oct 2 05:23:01 EDT 2018
Tue Oct 2 05:24:01 EDT 2018
Tue Oct 2 05:25:01 EDT 2018
Tue Oct 2 05:26:01 EDT 2018
Tue Oct 2 05:27:01 EDT 2018
Tue Oct 2 05:28:01 EDT 2018
Tue Oct 2 05:29:01 EDT 2018
Tue Oct 2 05:30:01 EDT 2018
Tue Oct 2 05:31:01 EDT 2018
Tue Oct 2 05:32:01 EDT 2018
Tue Oct 2 05:33:01 EDT 2018
Tue Oct 2 05:34:01 EDT 2018
Tue Oct 2 05:35:01 EDT 2018
Tue Oct 2 05:36:02 EDT 2018
Tue Oct 2 05:37:01 EDT 2018
Tue Oct 2 05:38:01 EDT 2018

So what do you think? this could be an Apache or PHP issue?

01 Oct
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

I can disable nginx if you have an idea of what can be causing this.

Charrua left a reply on Scheduler Running With Delay (not On Time)

@snapey I use apache with nginx, this is by default what comes with plesk, but I can disable nginx... you can see here: https://docs.plesk.com/en-US/onyx/administrator-guide/web-servers/apache-and-nginx-web-servers-linux/apache-with-nginx.70837/

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click thank you, I will post there too.

Charrua left a reply on Scheduler Only Running Some Tasks

Hi @D9705996 I tried to remove >> /dev/null 2>&1 from the cron job but no errors are in the output. The /var/log/cron does not show any errors, only cron executions.

There is only one schedule:run for all users. Checked.

At this time, I thinking is not a Laravel issue and more of a server issue, I have disabled the scheduler cron and enable a simple plain php cron to log when this is executed, and the same results are shown.

Cron log:

Oct 1 10:01:01 localhost CROND[2315] 
Oct 1 10:02:01 localhost CROND[2388] 
Oct 1 10:03:01 localhost CROND[2440] 
Oct 1 10:04:01 localhost CROND[2493] 
Oct 1 10:05:01 localhost CROND[2566] 
Oct 1 10:06:01 localhost CROND[2627] 
Oct 1 10:07:01 localhost CROND[2743] 

Task log:

Monday, 01-Oct-2018 10:00:01 EDT 
Monday, 01-Oct-2018 10:05:42 EDT 
Monday, 01-Oct-2018 10:05:42 EDT 
Monday, 01-Oct-2018 10:05:42 EDT 
Monday, 01-Oct-2018 10:05:42 EDT 
Monday, 01-Oct-2018 10:05:42 EDT 
Monday, 01-Oct-2018 10:06:01 EDT 
Monday, 01-Oct-2018 10:07:01 EDT 

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click my understanding of Linux stops here too, I have tried to restart the server but the same happens. This issue is driving me crazy. Thank you for your help.

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click I have disabled the laravel cron and setup another cron to log as you said timestamps, the same happens

Monday, 01-Oct-2018 10:00:01 EDT
Monday, 01-Oct-2018 10:05:42 EDT
Monday, 01-Oct-2018 10:05:42 EDT
Monday, 01-Oct-2018 10:05:42 EDT
Monday, 01-Oct-2018 10:05:42 EDT
Monday, 01-Oct-2018 10:05:42 EDT
Monday, 01-Oct-2018 10:06:01 EDT
Monday, 01-Oct-2018 10:07:01 EDT

Charrua left a reply on Scheduler Running With Delay (not On Time)

@click is not always at the same time:

2018-10-01 13:16:01 app.php
[2018-10-01 09:16:01] production.INFO: schedule call  
2018-10-01 13:17:01 app.php
[2018-10-01 09:17:01] production.INFO: schedule call  
2018-10-01 13:18:01 app.php
[2018-10-01 09:18:01] production.INFO: schedule call  
2018-10-01 13:19:01 app.php
[2018-10-01 09:19:02] production.INFO: schedule call  
2018-10-01 13:20:01 app.php
[2018-10-01 09:20:01] production.INFO: schedule call  
2018-10-01 13:23:22 app.php
2018-10-01 13:23:22 app.php
2018-10-01 13:23:22 app.php
[2018-10-01 09:23:22] production.INFO: schedule call  
[2018-10-01 09:23:22] production.INFO: schedule call  
[2018-10-01 09:23:22] production.INFO: schedule call  
2018-10-01 13:24:01 app.php
[2018-10-01 09:24:01] production.INFO: schedule call  
2018-10-01 13:25:01 app.php
[2018-10-01 09:25:01] production.INFO: schedule call  
2018-10-01 13:26:01 app.php
[2018-10-01 09:26:01] production.INFO: schedule call 

Charrua left a reply on Scheduler Running With Delay (not On Time)

@shez1983 When I say system is locked, I mean that if I run an any artisan command at 16:34:34, it will be queued and run at 16:37:53 (see the scheduler log I posted before). The server does not show any high load or any errors that I can relate to the times that this happens.

@Snapey web server is a Digital Ocean Droplet (if this is your question)

I don't even know if this is a php or more of a server issue... Because cron are executed on time but the artisan commands are like queued. Or maybe cron are queued too..

Charrua left a reply on Scheduler Running With Delay (not On Time)

CentOS 7.4 x64, 1vcpu, 2gbRAM, using Plesk and PHP-FPM 7.1

I think this is more of a server miss-config than a Laravel issue at this moment.

30 Sep
6 months ago

Charrua left a reply on Scheduler Running With Delay (not On Time)

@shez1983 I have tested with another cron job, independent of laravel. And the cron is also delayed when the system is "locked", it seems more of a server failure or php failure than a Laravel issue. The strange is that I can't find any errors related.

Charrua left a reply on Scheduler Running With Delay (not On Time)

Hi @Snapey I have fresh results:

I have discovered that if I execute any artisan command during the "hang up" it takes forever. Lets say you run any artisan command at 16:24 this command is not resolved until 16:27:31 (when the system is "locked out")

I have no more ideas... Have looked in logs and all that but NO CLUE. I think is not Laravel, maybe is a server issue. Server load is really little, is a droplet for a private app with 15 users. Mysql queries are not slow (I have activate the slow query log)

Cron log:

Sep 30 16:20:01 localhost CROND[28616]
Sep 30 16:21:01 localhost CROND[854]
Sep 30 16:22:02 localhost CROND[988]
Sep 30 16:23:01 localhost CROND[1062]
Sep 30 16:24:01 localhost CROND[1132]
Sep 30 16:25:01 localhost CROND[1199]
Sep 30 16:26:01 localhost CROND[1255]
Sep 30 16:27:01 localhost CROND[1315]
Sep 30 16:28:01 localhost CROND[1411]
Sep 30 16:29:01 localhost CROND[1508]
Sep 30 16:30:01 localhost CROND[1599]
Sep 30 16:31:01 localhost CROND[1670]
Sep 30 16:32:01 localhost CROND[1742]
Sep 30 16:33:01 localhost CROND[1807]
Sep 30 16:34:01 localhost CROND[1874]
Sep 30 16:35:01 localhost CROND[1936]
Sep 30 16:36:01 localhost CROND[1995]
Sep 30 16:37:01 localhost CROND[2062]

Scheduler log:

2018-09-30 16:20:12] production.INFO: schedule call  
[2018-09-30 16:21:01] production.INFO: schedule call  
[2018-09-30 16:22:02] production.INFO: schedule call  
[2018-09-30 16:23:01] production.INFO: schedule call  
[2018-09-30 16:27:31] production.INFO: schedule call  
[2018-09-30 16:27:31] production.INFO: schedule call  
[2018-09-30 16:27:31] production.INFO: schedule call  
[2018-09-30 16:27:31] production.INFO: schedule call  
[2018-09-30 16:28:01] production.INFO: schedule call  
[2018-09-30 16:29:01] production.INFO: schedule call  
[2018-09-30 16:30:01] production.INFO: schedule call  
[2018-09-30 16:31:01] production.INFO: schedule call  
[2018-09-30 16:32:02] production.INFO: schedule call  
[2018-09-30 16:33:01] production.INFO: schedule call  
[2018-09-30 16:37:53] production.INFO: schedule call  
[2018-09-30 16:37:53] production.INFO: schedule call  
[2018-09-30 16:37:53] production.INFO: schedule call  
[2018-09-30 16:37:53] production.INFO: schedule call  

Charrua started a new conversation Scheduler Running With Delay (not On Time)

Laravel 5.5 PHP 7.1

I have a strange issue on production server that delays the scheduler so tasks are not fired on time. It seems that for some reason the command artisan schedule:run sometimes takes time to load. If I run artisan schedule:run from console, it runs immediately, the issue is when is fired with the cron job. I have set the cron to fire by 5 minutes instead of all minutes to see more clear.

Cron log:

Sep 29 10:05:01 localhost CROND[17311]
Sep 29 10:10:01 localhost CROND[17846]
Sep 29 10:15:01 localhost CROND[18165]

Scheduler log:

Received ping at Saturday, 29-Sep-2018 10:06:11 EDT 
Received ping at Saturday, 29-Sep-2018 10:10:01 EDT 
Received ping at Saturday, 29-Sep-2018 10:18:55 EDT

The only task the scheduler has is a simple closure to measure time, no complex tasks.

$schedule->call(function () {
            return true;
        })
        ->everyMinute()
        ->pingBefore('...')

Somebody told me this could be a server load issue or clock sync, after running uptime; sar -q; etc the results are 10:52:05 up 4:29, 1 user, load average: 0,02, 0,04, 0,05 and clock is on sync.

The real issue is that if I have a task set to run eg at 10:05, it never runs, because the scheduler is loaded at 10:06.

Any ideas?

28 Sep
6 months ago

Charrua left a reply on Scheduler Running Strange

@Snapey I agree with you is like queuing somewhere, I'm not queuing mail, and if you see the code I'm using thenPing() function and the time registry in cronhub (cron monitor) is the same.

Charrua left a reply on Scheduler Running Strange

te issue is when running scheduler at a digital ocean server, if I run it locally no problems. Any ideas?