erb_lint_daemon 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdc26da9b1dda23331f802872d2a0561738a81ba9f0e2a611b6b05a4d5e26d73
4
- data.tar.gz: d68dd023eaafa82313c1dddfd60829f0b2299295b178e2f0d1c2fbb2feac4fcf
3
+ metadata.gz: aa7eed35cc085c04ff080b681c399889b01945d80940254c719f0d803e684d93
4
+ data.tar.gz: '01492be529e480995bec50f8c2ed0a3f1ef40d2814b166fd06c17889842c0611'
5
5
  SHA512:
6
- metadata.gz: 7b780b1a7325e6331592d16d3b50dd83506486c6d0d5ca0e66626323fdb80bd0678783b88115df591744da4eee3ebf61b8ce62cbbb3ddd7046504fd73c635092
7
- data.tar.gz: 31078d85fb5520fc23042815475e23e3f4bae7e94da8e4bcf58689b83d2cb403ec95503520908bf1bad6ed323389caa612fa4cb971c791b81992275775bd7239
6
+ metadata.gz: 53fca250bfbd43dbbda153e9ed7f39f6a627bd2908b59e96e69d08d44a9aa8cbbadacdc3dfd13df3b933b0ddc84aa64e608ff0b76cad819f8e51e4c5421e530f
7
+ data.tar.gz: 62f4468f1a7c8ca8fd2768b755dee42f45be4eb826d28ec1275c39ad87669c0b878467a57bb1115238d294562692dd2c0621212d648510fa9d3ea0791212306c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- erb_lint_daemon (0.1.2)
4
+ erb_lint_daemon (0.1.4)
5
5
  erb_lint
6
6
 
7
7
  GEM
data/ext/client.go CHANGED
@@ -6,6 +6,8 @@ import (
6
6
  "io"
7
7
  "net"
8
8
  "os"
9
+ "os/exec"
10
+ "time"
9
11
  )
10
12
 
11
13
  const socketPath = "/tmp/erb_lint_daemon.sock"
@@ -20,7 +22,21 @@ type Response struct {
20
22
  Status int `json:"status"`
21
23
  }
22
24
 
25
+ func startDaemon() error {
26
+ fmt.Println("Starting ERB Lint Daemon...")
27
+ // Use the same ruby command but ensure we are running the server correctly.
28
+ // We'll use -e to require and start.
29
+ cmd := exec.Command("ruby", "-Ilib", "-e", "require 'erb_lint_daemon/server'; ErbLintDaemon::Server.new.start")
30
+ cmd.Env = append(os.Environ(), "DAEMONIZE=true")
31
+ err := cmd.Start()
32
+ if err != nil {
33
+ return err
34
+ }
35
+ return nil
36
+ }
37
+
23
38
  func main() {
39
+ start := time.Now()
24
40
  cwd, err := os.Getwd()
25
41
  if err != nil {
26
42
  fmt.Fprintf(os.Stderr, "Error getting CWD: %v\n", err)
@@ -32,11 +48,24 @@ func main() {
32
48
  Cwd: cwd,
33
49
  }
34
50
 
35
- conn, err := net.Dial("unix", socketPath)
51
+ var conn net.Conn
52
+ for i := 0; i < 15; i++ { // Increased retries
53
+ conn, err = net.Dial("unix", socketPath)
54
+ if err == nil {
55
+ break
56
+ }
57
+
58
+ if i == 0 {
59
+ if err := startDaemon(); err != nil {
60
+ fmt.Fprintf(os.Stderr, "Error starting daemon: %v\n", err)
61
+ os.Exit(1)
62
+ }
63
+ }
64
+ time.Sleep(200 * time.Millisecond)
65
+ }
66
+
36
67
  if err != nil {
37
- // If daemon is not running, we could fallback or error.
38
- // For now, let's error.
39
- fmt.Fprintf(os.Stderr, "Error connecting to daemon: %v\n", err)
68
+ fmt.Fprintf(os.Stderr, "Error connecting to daemon after retries: %v\n", err)
40
69
  os.Exit(1)
41
70
  }
42
71
  defer conn.Close()
@@ -70,5 +99,10 @@ func main() {
70
99
  }
71
100
 
72
101
  fmt.Print(resp.Output)
102
+
103
+ // Only show timing if not in a quiet mode or if explicitly requested?
104
+ // For now, let's just print it to stderr so it doesn't interfere with output.
105
+ fmt.Fprintf(os.Stderr, "\nFinished in %v\n", time.Since(start))
106
+
73
107
  os.Exit(resp.Status)
74
108
  }
@@ -8,6 +8,7 @@ module ErbLintDaemon
8
8
  SOCKET_PATH = '/tmp/erb_lint_daemon.sock'
9
9
 
10
10
  def start
11
+ Process.daemon(true) if ENV['DAEMONIZE'] == 'true'
11
12
  File.unlink(SOCKET_PATH) if File.exist?(SOCKET_PATH)
12
13
  server = UNIXServer.new(SOCKET_PATH)
13
14
  puts "ERB Lint Daemon started on #{SOCKET_PATH}"
@@ -49,6 +50,8 @@ module ErbLintDaemon
49
50
  @cli.instance_variable_set(:@options, @default_options.dup)
50
51
  @cli.instance_variable_set(:@files, nil)
51
52
  @cli.instance_variable_set(:@lint_files, nil)
53
+ @cli.instance_variable_set(:@config, nil)
54
+ @cli.instance_variable_set(:@config_filename, nil)
52
55
 
53
56
  cli = @cli
54
57
 
@@ -1,3 +1,3 @@
1
1
  module ErbLintDaemon
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb_lint_daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owais Khan
@@ -78,7 +78,7 @@ post_install_message: |
78
78
  compiled binary directly to bypass the RubyGems wrapper overhead (~100ms).
79
79
 
80
80
  The binary is located at:
81
- <GEM_HOME>/gems/erb_lint_daemon-0.1.3/bin/erb_lint_client_bin
81
+ <GEM_HOME>/gems/erb_lint_daemon-0.1.4/bin/erb_lint_client_bin
82
82
 
83
83
  You can symlink it to your path, e.g.:
84
84
  ln -s $(gem which erb_lint_daemon | sed 's|lib/erb_lint_daemon.rb|bin/erb_lint_client_bin|') /usr/local/bin/erb_lint_client