Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redudant reloads with --watch flag and recommended location of SQLite database #397

Closed
sybbear opened this issue Oct 5, 2021 · 6 comments · Fixed by #867
Closed

Redudant reloads with --watch flag and recommended location of SQLite database #397

sybbear opened this issue Oct 5, 2021 · 6 comments · Fixed by #867

Comments

@sybbear
Copy link
Contributor

sybbear commented Oct 5, 2021

  • Octane Version: 1.0.12
  • Laravel Version: 8.62.0
  • Database Driver & Version: SQLite

Description:

This is an issue with default boilerplate code, which causes redundant Octane server reloads with --watch flag when using .sqlite database according to Laravel documentation.

According to https://laravel.com/docs/8.x/database#sqlite-configuration
And .gitignore in laravel/laravel: https://github.com/laravel/laravel/blob/8.x/database/.gitignore
*.sqlite database should be in /database folder.

Then watch flag in config/octane.php covers watching /database folder by default:
https://github.com/laravel/octane/blob/1.x/config/octane.php#L186

This can potentially cause a significant amount of server reloads on:

  • Local environments during development
  • Production environments where --watch flag is needed

As running octane:start command does not automatically tell which files were changed, it is very easy to get confused as to why reloads happen (especially for new developers) on requests that write to the database.

Resolution suggestions

  • Ignore watching /database dir (These are supposed to be run from CLI anyway)
  • Watch only .php files
@driesvints
Copy link
Member

Can you add !*.sqlite to that list to see if it ignore the watching?

@driesvints
Copy link
Member

Hey @sybbear. While your issue is straightforward and I'd expect to get the issue you're experiencing I couldn't reproduce the issue. Octane doesn't reload for me upon changes to the database.sqlite file.

I also see you've added an invalid Laravel version. 8.68.0 doesn't exists yet. So I suspect something is amis on your end. If you can give me clear step-by-step instructions on how to reproduce the issue I'll take another look. Thanks.

@sybbear
Copy link
Contributor Author

sybbear commented Oct 9, 2021

Hi @driesvints, apologies for delay.
There was a typo and the actual laravel/framework version is 8.62.0, I fixed it now in the description.
However, the reloads still happen with current octane watch configuration.

Reproducing the issue:
Artisan command for writing to DB

Artisan::command('sqlite-write', function () {
    \Schema::connection('sqlite')->create('test', function (\Illuminate\Database\Schema\Blueprint $table) {
        $table->id();
        $table->text('text');
    });
    DB::connection('sqlite')->table('test')->insert(['text' => 'TestText']);
    \Schema::connection('sqlite')->drop('test');
});

Start Octane
Screenshot 2021-10-09 at 12 31 50

Run command
Screenshot 2021-10-09 at 12 35 04

@sybbear
Copy link
Contributor Author

sybbear commented Oct 9, 2021

Having /database/!*.sqlite instead of /database seem to do the trick.

@driesvints
Copy link
Member

@sybbear that won't reload things for other files in /database anymore I think. I'm sorry but I don't seem to be able to reproduce this problem. Since the above solves the situation for you I suggest you definitely add that to your own config file. If we get more reports for this we can have a further look into this. Thanks

@sybbear
Copy link
Contributor Author

sybbear commented Oct 11, 2021

Got you and thank you for suggesting workaround 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants