Skip to content

Commit

Permalink
Moved VERSION out of libwebsocketd and into main app
Browse files Browse the repository at this point in the history
  • Loading branch information
jwalnes committed Nov 20, 2013
1 parent 89d3e3b commit 65ffba7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,20 @@ func parseCommandLine() Config {
config.ScriptDir = *scriptDirFlag
config.DevConsole = *devConsoleFlag
config.StartupTime = time.Now()
config.ServerSoftware = fmt.Sprintf("websocketd/%s", Version())

if len(os.Args) == 1 {
PrintHelp()
os.Exit(1)
}

if *versionFlag {
fmt.Printf("%s %s\n", filepath.Base(os.Args[0]), libwebsocketd.Version())
fmt.Printf("%s %s\n", filepath.Base(os.Args[0]), Version())
os.Exit(2)
}

if *licenseFlag {
fmt.Printf("%s %s\n", filepath.Base(os.Args[0]), libwebsocketd.Version())
fmt.Printf("%s %s\n", filepath.Base(os.Args[0]), Version())
fmt.Printf("%s\n", libwebsocketd.License)
os.Exit(2)
}
Expand Down
4 changes: 1 addition & 3 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"os"
"path/filepath"
"strings"

"github.com/joewalnes/websocketd/libwebsocketd"
)

const (
Expand Down Expand Up @@ -81,6 +79,6 @@ BSD license: Run '{{binary}} --license' for details.
func PrintHelp() {
msg := strings.Trim(help, " \n")
msg = strings.Replace(msg, "{{binary}}", filepath.Base(os.Args[0]), -1)
msg = strings.Replace(msg, "{{version}}", libwebsocketd.Version(), -1)
msg = strings.Replace(msg, "{{version}}", Version(), -1)
fmt.Fprintf(os.Stderr, "%s\n", msg)
}
1 change: 1 addition & 0 deletions libwebsocketd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ type Config struct {
UsingScriptDir bool // Are we running with a script dir.
StartupTime time.Time // Server startup time (used for dev console caching).
DevConsole bool // Enable dev console.
ServerSoftware string // Value to pass to SERVER_SOFTWARE environment variable (e.g. websocketd/1.2.3).
Env []string // Additional environment variables to pass to process ("key=value").
}
2 changes: 1 addition & 1 deletion libwebsocketd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func createEnv(ws *websocket.Conn, config *Config, urlInfo *URLInfo, id string)
env = appendEnv(env, "SERVER_NAME", serverName)
env = appendEnv(env, "SERVER_PORT", serverPort)
env = appendEnv(env, "SERVER_PROTOCOL", req.Proto)
env = appendEnv(env, "SERVER_SOFTWARE", fmt.Sprintf("websocketd/%s", Version()))
env = appendEnv(env, "SERVER_SOFTWARE", config.ServerSoftware)
env = appendEnv(env, "GATEWAY_INTERFACE", gatewayInterface)
env = appendEnv(env, "REQUEST_METHOD", req.Method)
env = appendEnv(env, "SCRIPT_NAME", urlInfo.ScriptPath)
Expand Down
10 changes: 5 additions & 5 deletions libwebsocketd/process_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package libwebsocketd
import (
"bufio"
"io"
"syscall"
"syscall"
)

type ProcessEndpoint struct {
Expand All @@ -32,10 +32,10 @@ func (pe *ProcessEndpoint) Terminate() {
err := pe.process.cmd.Process.Signal(syscall.SIGINT)
if err != nil {
pe.log.Debug("process", "Failed to Interupt process %v: %s, attempting to kill", pe.process.cmd.Process.Pid, err)
err = pe.process.cmd.Process.Kill()
if err != nil {
pe.log.Debug("process", "Failed to Kill process %v: %s", pe.process.cmd.Process.Pid, err)
}
err = pe.process.cmd.Process.Kill()
if err != nil {
pe.log.Debug("process", "Failed to Kill process %v: %s", pe.process.cmd.Process.Pid, err)
}
}

pe.process.cmd.Wait()
Expand Down
2 changes: 1 addition & 1 deletion libwebsocketd/version.go → version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package libwebsocketd
package main

// This value can be set for releases at build time using:
// go {build|run} -ldflags "-X main.version 1.2.3.4".
Expand Down

0 comments on commit 65ffba7

Please sign in to comment.