-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
start-api automatic reload does not appear to be doing anything #901
Comments
You will need to build every time. The behavior is you do not need to restart the command and can update the folders with new code and have it reflected when hitting the api. With the introduction of Closing as this is working as intended. |
when I run
Which suggests that automatic reloading is the intended behavior |
@felixhageloh Yes but that 'auto reloading' is not 'auto building'. The reloading in this is describing that you can update the contents of the If you are using build, what this is saying is you can build the function without needing to restart. This is because build generates a template that is used behind the scenes that points to a build location. The confusion comes from, you as a customer only interact with the non-built function/template while the invoke can (if using build) interact with the generated built template. Maybe a rewording is in order here to make the expectation better but it is working as intended. I create #921 to track the work for 'auto building' through Note: That output was from the pre- |
@jfuss thanks for the clarification. I spent some time reading the docs in the meantime and they also all clearly state that you need to run build again. |
Hey guys, So, we created a small npm package based in nodemon (samwatch): https://www.npmjs.com/package/samwatch https://github.com/mxitgo/samwatch The way it works is, it copies your js/json files as you save them from the source folder to the corresponding .aws-sam/build folder (as long as the names are the same for your lambda and the code uri in template.yaml). That is useful to see your changes reflected on the fly if you are running sam local start-api, so you don't have to run sam build after every change. On the other hand, if the corresponding file copy is not within the .aws-sam/build folder already, the package will trigger a sam build (unless you use n parameter). The package has helped us get a hot reload feeling for our local lambda function development with sam. I hope anyone can find it useful. Thanks! |
Hi @felixhageloh. maybe it is too late now but it can help to solve this issue. Mounting /media/valero61/SWA/ubuntu/workspace/cunaguaro product cataloge/.aws-sam/build/getHomePage I deleted the build folder and run sam local invoke getHomePage, now container mounts the path to the root folder of the project. and now hot-reload is working again. Mounting /media/valero61/SWA/ubuntu/workspace/cunaguaro product cataloge as /var/task:ro,delegated inside runtime container |
For local development I remove the .aws-sam build folder:
I do watch for typescript compilation during hot-reloading. To answer your question @ryancole, |
@jfuss I understand now that this is intended behavior, but could I suggest that you at least re-word the output of the Eventual hot-reloading would be nice, but for now, please don't confuse brand new users with the message that implies hot-reloading. |
The confusion is that This was confusing though, and I can't remember if the documentation mentions this. |
Fascinating. Thanks for the tip @alex-nishikawa! I still think that message in the SAM start-api output should be more clear about this, but at least now I learned 😁 |
This is true, what how does it work with the dependencies? I'm using ruby and even after running |
The statements about where Regardless, if you use |
|
Forgive my ignorance and inexperience, but what is the value of I can't think of any reason I'd want to have edited source code in my source tree with a running SO, what am I missing? There must be a good reason you've chosen to provide this separation of commands. You've written above "...but it is working as intended". I don't think anyone doubts it works as intended, what I'm (and others likely are) curious about is why you intend it to work this way? What is the workflow that requires this behavior? Thanks. |
Here is another relevant thread: #1921 |
Ahahaha! This was the exact same Google Search I just did and landed here. Yes, I agree, this message is overly confusing. I also weren't sure why my project wasn't hot reloading. After reading this, seems like sam just can't do this just yet. Sad. |
I also came across this recently, hoping to get hot reload type functionality to make local development with the AWS Serverless services easier. I've seen some other work arounds on other aws-sam-cli Github issues saying an option is to move your dependencies into a Lambda layer, or to develop against the Even though this is a super old issue I thought I'd comment incase it's of use to someone else. I came up with this semi hack to get
where: Note - the above command will run continually if your I'm using This at least reduces the time spent trying to figure out why your code changes aren't being reflected when calling the local SAM API endpoint, because you simply forgot to run |
If your project uses Golang, you can work with air to solve this problem. .air.toml
Makefile
|
Using sam local start-api requires restarting the server for every change, which is really disrupting the flow of development. Could we add an automatic build step to handle changes dynamically? This would make development smoother and keep us from having to restart manually all the time. Obviously, I think this might be the intended functionality but when using SAM build it doesn't work - anyway around this? I might have missed something in this thread so please let me know if there was a solution to this issue. |
Currently I use the same as what @shzxcv mentioned but instead of both running on background, I only background air
so I can still debug and when I ctrl+c both cancels as well. No need to stop |
Hi folks,
I'm running the following command:
sam local start-api
I'm running the above command inside of a directory that I created using the
sam --init
command. So, it's a directory with atemplate.yaml
file in it, and an actual node.js lamba function project folder.The console output from
sam
says that I do not need to restart the CLI for changes to take affect, but modifying my code does not appear to cause any sort of automatic reload.Do I have to do anything specific to allow this to auto reload? I'm running Windows 10.
The text was updated successfully, but these errors were encountered: