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 +4 -4
- data/Gemfile.lock +1 -1
- data/ext/client.go +38 -4
- data/lib/erb_lint_daemon/server.rb +3 -0
- data/lib/erb_lint_daemon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa7eed35cc085c04ff080b681c399889b01945d80940254c719f0d803e684d93
|
|
4
|
+
data.tar.gz: '01492be529e480995bec50f8c2ed0a3f1ef40d2814b166fd06c17889842c0611'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53fca250bfbd43dbbda153e9ed7f39f6a627bd2908b59e96e69d08d44a9aa8cbbadacdc3dfd13df3b933b0ddc84aa64e608ff0b76cad819f8e51e4c5421e530f
|
|
7
|
+
data.tar.gz: 62f4468f1a7c8ca8fd2768b755dee42f45be4eb826d28ec1275c39ad87669c0b878467a57bb1115238d294562692dd2c0621212d648510fa9d3ea0791212306c
|
data/Gemfile.lock
CHANGED
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
|
|
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
|
-
|
|
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
|
|
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.
|
|
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.
|
|
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
|