-
Notifications
You must be signed in to change notification settings - Fork 178
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
Added verbage for setting up AWS Lambda with Zappa. #167
Conversation
Cool, I will give this a go, I used to use Zappa for the Kodi Skill as well (but I have since changed my kodi skill to not be dependant on Zappa johnwheeler/flask-ask#197) |
So @digiltd did you use environment variables with that? I started down that path and got wrapped around a pole and stumbled upon Zappa. It doesn't add any code, just 2 dependencies. The Heroku deploy also adds a few dependencies (if you deploy from command line). Also wouldn't the WSGI wrapper that's referenced in your hyperlink be conditional to only this deployment? Then we'd need feature flags for the entry point based on what we are using to deploy, right? For reasons surrounding those concerns I would argue that this solution is perfectly fine, I found it enjoyable. |
Sorry, my fault, I wasn't clear enough. It was my Kodi skill I was talking about that no longer uses Zappa, not GeeMusic. I briefly tried to get GeeMusic working in the same way (without Zappa) but failed. The non-zappa way uses the standard Lambda "arn" address to connect to the Skill which is the thing I like about that method (compared to Zappa creating an API Gateway). But I don't think it would work with GeeMusic anyway given the way GeeMusic works so I didn't pursue it. I'm not against Zappa at all, my beef I had with it with the Kodi Skill was mainly due to all the extra bits it creates (API Gateway, time based triggers, additional users) which are fine and all above board. But I found that a lot of beginners (certainly on the Kodi forums) would Plus trying to find something in CloudWatch logs was always a challenge with the 4 min "keep warm" feature of zappa :) Note that none of the above is me commenting on your idea of using Zappa with GeeMusic, just some ramblings. I am gonna try GeeMusic using Zappa right now, would rather do that than my current solution of installing it on one of my digitalocean vps :) |
I didn't take it as snark one bit @digiltd so you're fine on that aspect. I was just challenging you to make sure I understood what I was talking about, with the validation of some external third party. I wanted to make sure I understood what it took to implement parts of what you were talking about. Considering there is an optional setup to use docker I cannot see this setup being too hard for anyone that already has this app deployed and working in production for themselves. That's just my $0.02. If you have trouble following my instructions let me know. I can clarify anything or help you debug. |
No starkyness read or taken :) But I think I need some hints as I'm stuck. A few questions... Is your install using aws/lambda/zappa to actually serve the files back to Alexa? Whilst I have been having some success getting it to work (logging into google music, finding tracks and then supposedly "streaming" them) I am not able to actually hear anything. When I try playing the alexa/stream/31232131 url from the log in a browser, I get Did you do any additional tweaking (increased memory/timeout) to the Lambda function? When you ran
Did you adjust any other files in the repo or was it a direct Anything out of the ordinary here: {
"dev": {
"app_function": "geemusic.app",
"aws_region": "eu-west-1",
"profile_name": "default",
"project_name": "geemusic",
"runtime": "python3.6",
"keep_warm": false,
"use_precompiled_packages": true,
"s3_bucket": "zappa-geemusic",
"environment_variables": {
"APP_URL":"https://123123123.execute-api.eu-west-1.amazonaws.com/dev",
"DEBUG_MODE": "False",
"GOOGLE_EMAIL":"[email protected]",
"GOOGLE_PASSWORD":"abc123",
"ANDROID_ID": "123123",
"USE_LIBRARY_FIRST": "True"
}
}
}
I am deploying from a digitalocean vps (Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-104-generic x86_64)) I am guessing you are deploying from a linux box? My main machine is a Mac, and as with previous zappa deployments there are issues due to when you When using lambda how does the server (in server.py) get initialised? When I say the `app_function" is "geemusic.app" this successfully starts the Skill (for handling the request from Alexa) but what starts the server that serves the audio files? To summarise, I have it working where I can call the skill "play playlist sleepy" and she responds "playing songs from Sleepy" looking at the logs it looks like everything is working, I can see the stream url (which looks something like: https://123123123.execute-api.eu-west-1.amazonaws.com/dev/alexa/stream/4432hjk2-2233-1111-4566-123123123) but I can't play it. Any ideas? |
You're spot on. The second half of the whole thing doesn't work. Thanks for spelling it out for me though. Thats gonna be a tommorrow thing as I'm busy for the remainder of today/tonight. |
Lol, no problem, though I had assumed it was a tried and tested method. Good luck |
I admittedly thought it was a google account issue on my end and not the AWS integration. I changed my google password not too long ago and forgot it yesterday and locked my account. Just figured it was that. Oops. |
I think I figured it out and will reopen once I fully verify. |
@digiltd I'm going to revisit this. The fix to |
So i swapped out the requirements.txt
But it also installs 0.9.7 even when I do |
Yup, exactly what I was seeing. Testing does have its benefits :) The Skill query side of it is not a problem for a Lambda, but they are not really suited to staying up and running in order to stream content. Though there might be a way, never say never :) |
@digiltd it streams from google play though doesn't it? We just pass the link through via a callback. That's my understanding so far at least. I have a breakthrough in why it might not work |
@digiltd hey man, I jumped back into this for fun. I am going to try to do this the old fashioned way, since you did it with kodi-alexa. So the geemusic app works similarly to kodi, where it takes the skill invocation, gets info from a google play music/kodi music/movie URL and streams it to your alexa device. What did you specify in the Lambda console for the Things I have tried for Handler:
All of them give me the same issues. I don't know what to do anymore. I'm stuck again. Any references or ideas you could throw out would be great! |
Good luck, it is on my list of things to investigate. Looking at my Lambda function, I have the handler set to I renamed
Hope it helps |
I jumped back into this one.
You need the Now we have to figure out what we can do to get around the body size being too long. All the other requests seem to go through fine. |
Gonna read through this tonight https://seancoates.com/blogs/lambda-payload-size-workaround/ |
@digiltd I saw that |
I don't think so, it uses it to store a cached version of the json requested from Kodi. I don't think an S3 redirect will help. Same developer created a way to listen to your music stored in Kodi through an Echo device. I haven't tried setting it up, I know it uses a db on his server (though he has provided the source) to link the accounts. Could be a starting point though https://lexigr.am/docs/what-is-koko.html |
But the current error message I have is basically screaming S3 redirect. Currently its failing on the redirect with |
I really think this is the solution because this is what I'm trying to fix and it seems like its basically a drop in replacement: https://github.com/fergyfresh/geemusic/blob/master/geemusic/controllers.py#L23-L25 |
Added setup to get this working on AWS Lambda.
I used Zappa which is a command line utility I've used before and given that its a music related app I thought that having a dependency on Zappa would be pretty cool. I don't force it on anyone though with the
requirements.txt
file, but I get them from this code to AWS in < 5 minutes just like the Heroku example does.If we want to add
awscli
andzappa
to dependencies I canpip freeze
my env and update the requirements.txt file.