Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Targeting a specific function when running sls wsgi commands #136

Closed
dan-bowen opened this issue May 3, 2020 · 4 comments
Closed

Targeting a specific function when running sls wsgi commands #136

dan-bowen opened this issue May 3, 2020 · 4 comments

Comments

@dan-bowen
Copy link

Hello,

Is it possible to target a specific function when running Flask commands?

I have 2 functions with exactly the same code but different settings.

functions:
  api: # for serving the web requests via API gateway with a low timeout
    handler: wsgi_handler.handler
    events:
      - http: ANY /
      - http: ANY {proxy+}
    timeout: 6
  admin: # for running Flask commands (no API gateway) and a longer timeout
    handler: wsgi_handler.handler
    timeout: 900

It appears that running

sls wsgi flask --command "db upgrade"

is targeting my api function.

The issue I am running into is the short timeout on the api function is causing my longer running Flask commands to fail. It would be great if I could target a specific function like so

sls wsgi flask --function admin --command "db upgrade"

If this is not currently supported I'm happy to investigate making a PR if you could point me in the right direction.

-Dan

P.S. Thanks for this plugin!

@logandk
Copy link
Owner

logandk commented May 5, 2020

Hi Dan,
Yes, having multiple functions with wsgi_handler.handler as the event handler is currently unsupported. It will basically pick the first function with this handler as the target for invocation.

I think it would make sense to add an extra argument specifying the function target, as you've suggested and I'm happy to accept a PR for this feature.

Thanks!

@dan-bowen
Copy link
Author

Thanks for the update. I'll see how far I can get with this over the next few weeks.

@felipeespitalher
Copy link
Contributor

felipeespitalher commented Dec 7, 2021

Hey @dan-bowen @logandk I'm facing the same problem then I created a PR to solve it.
Can you take a look pls?

#198

@dan-bowen
Copy link
Author

@felipeespitalher I think that PR solves a different issue than the one I am facing.

The issue here is having wsgi_handler.handler as the same handler for 2 different functions, and per @logandk comment the code is choosing the first one rather than being able to target a specific function.

Repository owner locked and limited conversation to collaborators Apr 4, 2022
@logandk logandk converted this issue into discussion #210 Apr 4, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants