Skip to content

Run the watcher on a Thread when Rails boots instead of foreman ? #58

Closed
@b-nik

Description

@b-nik

Hello,

This is a idea for an alternative way to run the dartsass watcher without using foreman. I didn't start with a PR to add this because maybe it has some disadvantages I'm unaware of, or it might be unwanted.

So, instead of foreman, I changed my Rails config.ru file to spawn a thread that runs the dartsass watcher instead:

require_relative "config/environment"

if Rails.env.development?
  dart_watcher_thread = Thread.new { system("./bin/rails dartsass:watch") }
  at_exit { dart_watcher_thread.exit }
end

run Rails.application
Rails.application.load_server

For me, this offers a few advantages:

  1. No foreman dependency
  2. Terminal debugging (i.e. pry) still works
  3. Running ./bin/rails server is enough - this is minor, but probably removes some friction for people coming into dartsass and having to now change their usual start server command.

This feels like a better way, but of course I could be missing something. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions