Skip to content

CLI --watch option should kill previous process to be useful for long running scripts #1110

Description

@ceremcem

The --watch switch in CLI is intended for progressive script compilation and works well for that case. This feature is very useful while developing a long-running server side script as well.

However, it behaves unexpected when executing a long-running script, like with lsc -w myscript.ls. That starts just another instance before killing previous instance.

Expected

lsc -w should kill previous instance (if exists) and then start the new process.

Test case

sleep = (ms, f) -> set-timeout f, ms

i = 0 
console.log "script started."
<~ :lo(op) ~> 
    console.log "Hello #{i++}"
    <~ sleep 1000ms
    if i > 10
        return op!
    lo(op)
console.log "script ended."

Output is:

$ lsc -w test.ls 
script started.
Hello 0
Hello 1
Hello 2
script started. <--- Here the file is saved again
Hello 0
Hello 3
Hello 1
Hello 4
Hello 2
Hello 5
Hello 3
Hello 6
Hello 4
Hello 7
Hello 5
Hello 8
Hello 6
Hello 9
Hello 7
Hello 10
Hello 8
script ended.
Hello 9
Hello 10
script ended.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions