Class: Inertia::ViteDevServer

Inherits:
Rage::Daemon
  • Object
show all
Defined in:
lib/inertia/vite_dev_server.rb

Overview

A daemon that runs the Vite development server alongside the Rage process.

Instance Method Summary collapse

Instance Method Details

#cleanupObject



22
23
24
25
# File 'lib/inertia/vite_dev_server.rb', line 22

def cleanup
  Process.kill("TERM", @pid)
rescue Errno::ESRCH
end

#performObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/inertia/vite_dev_server.rb', line 6

def perform
  puts "INFO: Starting Vite dev server"

  config = Inertia.config.dev_server
  host, port = config.host, config.port

  command = "#{Frontend.package_runner} vite dev --clearScreen false --host #{host} --port #{port}"
  @pid = Process.spawn(command, chdir: Frontend.root)
  Process.wait(@pid)

  # Vite child process sometimes receives a shutdown signal first. The supervisor sees that
  # the Vite process has exited and schedules a restart before Rage processes its own shutdown.
  # The delay allows Rage to handle the signal, stop supervision, and avoid a confusing log message.
  sleep 0.1
end