ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

[New Feature]: Introduce a new CLI command/ flag `watch`, that restarts a Ballerina project when the source code changes

Open gayaldassanayake opened this issue 1 year ago • 0 comments

Description

Introduce a new CLI command (bal watch) or a flag (bal run --watch) to restart a running Ballerina service automatically, based on the file changes by a user.

Describe your problem(s)

Currently, when a user runs a service and a code change happens, the user needs to kill the bal run and retrigger it. This has to be done every time the code changes, which is cumbersome.

Describe your solution(s)

We can implement a file listener, that listens to any source code changes. This gets started with the command/ passed flag. It spawns a new process that runs bal run internally. If any change is to happen to the source code, the listener will get hit, the current bal run process will be terminated, and a new bal run will be executed.

Improvements

  • [ ] Extend the restart feature to programs that exit cleanly, without any services that hang indefinitely.
  • [ ] Allow manual restarting, even when no code changes occur. This eliminates the requirement for users to terminate the command and rerun when required.
  • [ ] Introducing a table in Ballerina.toml, if passing configs to configure the restarting process is needed.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

gayaldassanayake avatar Jun 10 '24 05:06 gayaldassanayake