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

Issue in django sls management commands #156

Closed
mmoallemi99 opened this issue Dec 9, 2020 · 10 comments
Closed

Issue in django sls management commands #156

mmoallemi99 opened this issue Dec 9, 2020 · 10 comments

Comments

@mmoallemi99
Copy link

Hi People,

I'm using serverless-wsgi==1.7.6 alongside serverless==2.2.0.

The problem is when I intend to run a management command as stated in the documents I must be executing this:

sls wsgi manage -c "update_containers"

But this raises an exception with this error message:

 
  Error --------------------------------------------------
 
  Error: Config file update_containers not found
      at Utils.findServicePath (/home/ubuntu/.npm-packages/lib/node_modules/serverless/lib/classes/Utils.js:109:15)
      at new Serverless (/home/ubuntu/.npm-packages/lib/node_modules/serverless/lib/Serverless.js:43:18)
      at Object.<anonymous> (/home/ubuntu/.npm-packages/lib/node_modules/serverless/scripts/serverless.js:35:14)
      at Module._compile (internal/modules/cjs/loader.js:1015:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
      at Module.load (internal/modules/cjs/loader.js:879:32)
      at Function.Module._load (internal/modules/cjs/loader.js:724:14)
      at Module.require (internal/modules/cjs/loader.js:903:19)
      at require (internal/modules/cjs/helpers.js:74:18)
      at Object.<anonymous> (/home/ubuntu/.npm-packages/lib/node_modules/serverless/bin/serverless.js:47:1)
      at Module._compile (internal/modules/cjs/loader.js:1015:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
      at Module.load (internal/modules/cjs/loader.js:879:32)
      at Function.Module._load (internal/modules/cjs/loader.js:724:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
      at internal/main/run_main_module.js:17:47
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.19.1
     Framework Version:         2.2.0
     Plugin Version:            4.0.4
     SDK Version:               2.3.2
     Components Version:        3.1.4

This command is the same as stated in the repo README.md file, but changing -c to --command fixes the problem!

So am I missing something here or -c is a broken argument?
And I would like to contribute to fix the problem, should I be updating the documents or fix handling -c arg just like --command?

Any guidance would be appreciated <3

@logandk
Copy link
Owner

logandk commented Dec 9, 2020

Indeed, this is the same issue as #132 - serverless started utilizing the -c argument

I haven't had time to look into it yet, but I think we should consider changing -c to another shorthand for --command. If you can determine which other shorthand would make sense, which is not reserved by the framework already, it should be a simple matter of replacing it in the code, tests and readme

@mmoallemi99
Copy link
Author

mmoallemi99 commented Dec 15, 2020

I guess if we start brainstorming about it we can end up with some valid candidates for the issue.

sls wsgi manage -t "<command_name>"
sls wsgi manage --task "<command_name>"
sls wsgi manage -a "<command_name>"
sls wsgi manage --action "<command_name>"
sls wsgi manage -x "<command_name>"
sls wsgi manage --execute "<command_name>"

And I think that it's better if we just change --command and -c together and deprecate --command in future.

@mmoallemi99
Copy link
Author

@logandk up

@logandk
Copy link
Owner

logandk commented Apr 25, 2021

Sorry, I haven't had any time to spare for this project in a while - I like your first proposal (-t/--task) if that flag is available. Not sure if you're still interested, but otherwise I'm leaving this comment for anyone else to pick up.

@mmoallemi99
Copy link
Author

Awesome!
Yes I'm still interested, I will take a look at it this weekend and open a PR so we can discuss further.

Cheers

@carlosfunk
Copy link

carlosfunk commented May 27, 2021

I started to take a look at this, none of the shortcuts were resolving for me until I added

this.hooks = {
	initialize: () => {
		this.options = this.serverless.processedInput.options;
	}

from serverless/serverless#9452

@carlosfunk
Copy link

carlosfunk commented May 27, 2021

Also nothing I tried could get me past the original error I was seeing, maybe the api for invoke has changed?

ServerlessError: Function "undefined" doesn't exist in this Service
	at Service.getFunction (...node_modules/serverless/lib/classes/Service.js:258:11)
	at AwsInvokeLocal.extendedValidate (...node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:84:56)
	at Object.before:invoke:local:loadEnvVars [as hook (...node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:46:20)
	at PluginManager.invoke (...node_modules/serverless/lib/classes/PluginManager.js:544:20)

@george-silva
Copy link

@carlosfunk any ideas on how to solve this?

@himynameisben
Copy link

You can use invoke to solve this issue temporarily.
For example,
change from

sls --function {function name} wsgi manage local --command 'check --list-tags'

to

sls invoke --function {function name} -d '{"_serverless-wsgi":{"command":"manage","data":"check --list-tags"}}'

same as others command
change from

sls wsgi exec -c "import math; print((1 + math.sqrt(5)) / 2)"

to:

sls invoke local --function {function name} --data '{"_serverless-wsgi":{"command":"exec","data":"import math; print((1 + math.sqrt(5)) / 2)"}}'

@george-silva
Copy link

Exacly what we did @himynameisben !

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

No branches or pull requests

5 participants