sandstorm-io / vagrant-spk

Packaging tool for Sandstorm, a self-hosting platform for web apps!
Apache License 2.0
55 stars 29 forks source link

Initalize MySQL Once #352

Closed ocdtrekkie closed 6 months ago

ocdtrekkie commented 6 months ago

So I believe this change is necessary to stabilize our lemp and uwsgi stacks, and fixes the roadblock I've been fighting on my own package. MySQL's documentation states --initialize should exit without changes if the directory isn't empty (aka, already initialized), but my guess is because we launch initialize without a password (or skip-grant-tables like our main process launch), it encounters an access error trying to verify the initialization is already done. I think the best choice is to just only initialize a grain once, it avoids some log cruft and is (probably) more efficient.

https://dev.mysql.com/doc/refman/8.0/en/data-directory-initialization.html#data-directory-initialization-procedure

I am also taking a behavior Ian used effectively in his grains and introducing it as a standard behavior, both for initializing and populating the database. Since the latter isn't always required, I'm including it in the template commented out.

ocdtrekkie commented 6 months ago

@orblivion @troyjfarrell If either of you were able to verify that a grain built with the php or python test apps can only launch once (aka, fail, if you let the grain shut down and attempt to reopen it) off master, but work correctly if you create them using this PR, I would really love to know I am not crazy.

ocdtrekkie commented 6 months ago

So I both simplified this and ensured it should work now even if the original grain wasn't created with this in place. Instead of initializing and leaving a file to check... it simply checks for a folder that should only exist if mysql has been initialized already.

orblivion commented 6 months ago

I tried both the php-app-to-package-for-sandstorm and python-app-to-package-for-sandstorm. With master they would initially load, but fail to load if I restarted the grain. With this branch they would still load after restarting the grain.

orblivion commented 6 months ago

(we're doing QA here so I'm being specific and redundant)