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

suggestion #1

Open
abdelhai opened this issue Mar 19, 2023 · 21 comments
Open

suggestion #1

abdelhai opened this issue Mar 19, 2023 · 21 comments

Comments

@abdelhai
Copy link

abdelhai commented Mar 19, 2023

great job. one suggestion, it's probably a better idea to install the PHP binary and pack it with the code ding the Deta build process. like what I did here with the Deno runtime: https://github.com/abdelhai/oden/blob/1a05cb08ad467c37b3c791b5803c1d6df7c03d0d/Spacefile#L6..L16

@tuefekci
Copy link
Owner

@abdelhai if I understand it right the build process runs locally that would make it really complicated to deploy/build from windows without using batch scripts which would be possible, but I get where you are coming from and marked it in my to-dos when I have time, mostly to make smaller bins if people don't need all the extensions.

This is at the moment more like a POC, I also need to optimize the base config, so timeout and memory is more optimized for deta and firstly the Web server needs to be replaced for real usage.

@abdelhai
Copy link
Author

the build runs on our build server, not locally.
awesome, great to have you in the community!

@tuefekci
Copy link
Owner

@abdelhai great did not know that than I will change it.

@tuefekci
Copy link
Owner

I apparently completely misunderstood how the new system works it's awesome I was still thinking we need to build bins locally because of lambda, but the new build process is awesome will change the whole setup here when I tested everything.

@tbdsux
Copy link

tbdsux commented Apr 1, 2023

I tried having a different spacefile from here: https://github.com/tbdsux/space-custom-apps/blob/main/php/Spacefile

It works for now, but not tested on more complex frameworks / applications.

@tuefekci
Copy link
Owner

tuefekci commented Apr 1, 2023

@tbdsux I'm doing it the same way now, but I use the Node.js base using it as a reverse proxy, so it handles static files and files from drive directly if configured.

Custom stuff will work, but everything which want to write outside /tmp will make problems.

@tbdsux
Copy link

tbdsux commented Apr 1, 2023

It would be a different issue if we include static files.

@tuefekci
Copy link
Owner

tuefekci commented Apr 1, 2023

@tbdsux your repo is btw. awesome looks like we have the same interpretation of fun ;)

I tried building nginx and FPM, but it overwhelmed me, killed the PHP process all the time not sure if there are deta or lambda limits to process creation etc. not really my field.

So I ended up with the Node.js reverse proxy. Debugging on the micro is kinda complicated, like always in these situations.

Also, the way how micros works makes it so that you could have multiple at the same time tried multi threading and reverse proxying via nginx, but that also ended up unstable not sure if it even makes sense to have multiple php -s servers on the same micro or if it always switches to a new one if one has load should read more about that.

So I ended up with the setup I'm working on at the moment, routing everything static or on drive through express for performance and fallback to the PHP server is there is no resolution. I have some other performance ideas, but I need to test at some point if I'm just wasting time.

@tbdsux
Copy link

tbdsux commented Apr 1, 2023

Deta micros is serverless while Nginx is a web server, I don't think they complement each other, I'm not sure.
I tried running Laravel with the Spacefile but it needs the session extension, maybe if we can create a separate build of static-php-cli with required extensions, we can test more. Also there's some limitations with static-php-cli as of now as I read on its repo.

Hey thanks for the compliment btw :)

@tuefekci
Copy link
Owner

tuefekci commented Apr 1, 2023

Sessions will not really work in the php-cli context, that's why I thought of using nginx for fpm/cgi because it's pretty easy to build statically node or python has probably a CGI module as well.

Nginx runs perfectly find in the micro context it's just I think the php-cli server does not like running multiple at the same time or something like that it could probably be fixed by having a watcher, but it gets overengineered pretty quickly and needlessly.

Building PHP statically is a pain in the ass, trying around with it for years and never got anything out of it, which is consistent if you don't build all the time,

I will try to modify one of my older scripts for building fpm and make changes, so it builds the latest version if it works out we could probably have a proper server version as well. Cli is my preferred choice, but most scripts are optimized for the web version.

Sessions will still be an issue tho because we have ephemeral instances I'm already working around with syncing with base and drive, but that will not really work for sessions.
https://shiflett.org/articles/storing-sessions-in-a-database would be a way, but I'm not sure if boilerplate code before execution will break other things, so that probably should wait for user request if somebody needs it.

@tbdsux
Copy link

tbdsux commented Apr 1, 2023

Wow, amazing!

Would love to see your progress on this one.

@tuefekci
Copy link
Owner

tuefekci commented Apr 2, 2023

@tuefekci
Copy link
Owner

tuefekci commented Apr 2, 2023

that's my active work repo https://github.com/tuefekci/deta-php-server still not done for FPM I will look into it tomorrow when im done with the base on the PHP server.

@tuefekci
Copy link
Owner

tuefekci commented Apr 5, 2023

I implemented sessions via session_set_save_handler but it looks like its not really available so for session we would need a custom cgi build but then we also need all the extension build against it so the question is do we need reliable sessions.

Error is btw. Call to undefined function session_set_save_handler() i never really tried to do more than setting the path manually if somebody else knows better feel free to push your own implementation.

@yakuv0
Copy link

yakuv0 commented Aug 21, 2023

much appreciation, as it seem @abdelhai 's suggestion in having a prebuilt php unable to push due to the size of php binary ~33mb

@abdelhai
Copy link
Author

33mb shouldn't be an issue to push. what error are you getting?

@yakuv0
Copy link

yakuv0 commented Aug 21, 2023

@abdelhai
✓ Successfully started your build! ✓ Successfully pushed your Spacefile! ❗ Failed to push code: failed to push code, Internal server error

did a push without binary and it succeeded although the deta documentation mentions max file size 10 mb.

@yakuv0
Copy link

yakuv0 commented Aug 21, 2023

ok now getting ❗ Failed to push code: failed to push code, unauthorized

@yakuv0
Copy link

yakuv0 commented Aug 21, 2023

builder log

DEV build hare-k82u pending
DEV build rat-bnbv pending
DEV build titmouse-mref timed out
DEV build pika-6zkj timed out
DEV new revision mayfly-xjfe
DEV build mayfly-xjfe complete
DEV build wolf-y8pl timed out
DEV build elk-kvnx timed out

@abdelhai
Copy link
Author

ok, please report on our discord. this is a separate issue. https://go.deta.dev/discord

@yakuv0
Copy link

yakuv0 commented Aug 21, 2023

tracing upload when push always result in failure when reaching 10mb.
however deta-php-server contains an implementation on downloading php in Spacefile.

@abdelhai

33mb shouldn't be an issue to push. what error are you getting?

any specifics on that ?! like what should be the max file size and maximum files allowed when push ?! it always same result when reaching 10mb

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

No branches or pull requests

4 participants