-
Notifications
You must be signed in to change notification settings - Fork 7
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
watchexec not work for java -jar #164
Comments
This is unnecessary. The Java buildpacks will determine the correct process type, even with reloading enabled. The process type will be called
How are you doing this specifically? Are you using Tilt, or some other way to reload them?
Usually, when you deploy with buildpacks, it explodes your JAR file and runs from disk. This works much better when using watchexec because individual files can be updated. This works great with Tilt and your IDE so you can save and automatically have changes pushed to your container. If your build results in a JAR file, then you have to update the entire JAR file every time you want the process to reload, which is less convenient.
Check out this: https://paketo.io/docs/howto/java/#using-tilt-with-paketo-buildpacks |
Hi @dmikusa, I just want to test
No, I mount a file to a pod and package the jar file locally, then upload it to the cloud storage, then the file in the mount path will be updated. Although it's less convenient, the
If customers deploy apps in the cloud platform, like Azure Spring Apps, then maybe customers can't see the backend pods in k8s, In such case, I think a tool like tilt is not very useful. But if customers manage their own k8s, then tools like tilt is useful, is it right? |
I don't know exactly what watchexec is doing to check for modified files, but I believe it's using OS-level features to be notified when files have changes. I really can't say how well watchexec would work with a cloud-storage backed file system or volume mount. What I can say is that when watchexec notices a change it will not restart the container. It will reload the process in the container. When watchexec is enabled, it runs as the parent process and spawns your application as a child process. When it detects a changed file, it'll kill your process & spawn a new process. That means you can tell if it's picking up file changes by looking to see if the pid of your application process in the container changes. You can also look at the logs, you should see the JVM & Spring Boot restart when your app restarts, so there will be new log entries when that happens.
This is getting out of my area of expertise, but I believe Tilt has to have access to the K8s API to deploy the pod where your app runs.
Yes, watchexec is a general solution. It watches for file changes and reloads the whole process. We started with this in buildpacks because it's very simple to implement. The performance for most microservice-style apps isn't going to be that bad. Even if it takes 1-2 seconds to restart your app, by the time you save in your IDE, switch to the browser, and hit refresh, it's likely to have restarted. We'd originally talked about integrating with Spring Boot Dev Tools and we still might, but I think we're just waiting to see how much use folks get out of this type of setup and if it's worth the extra effort to utilize a tool like that. If anyone is interested in contributing a PR for Spring Boot Dev Tools support that would be fantastic & I'd be happy to talk through that. |
I config
BP_LIVE_RELOAD_ENABLED
env to enable live process reloading, then create aProcfile
to determine my process type. After that, deploy the app to k8sProcfile:
Build logs
exec to pod, shows process:
Then I change my jar file and update some files, then the container doesn't restart. but the jar file has already been updated.
Another question
If I deploy the sprint boot project to a cloud platform, like azure, what's the usage to watch a workspace?
E.g
If I watch a sprint boot project
the workspace is default
/workspace
,I can't update the class file in the /workspace directly, so what's the meaning of watching this?
Expected Behavior
the jar file update should be detected and restart the container
Current Behavior
the jar file changed but the container is not restarted
Possible Solution
Steps to Reproduce
Motivations
The text was updated successfully, but these errors were encountered: