diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 217bb46..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:latest -MAINTAINER Liang Ding - -ADD . /go/src/github.com/b3log/wide -ADD vendor/ /go/src/ -RUN go install github.com/visualfc/gotools github.com/nsf/gocode github.com/bradfitz/goimports - -RUN useradd wide && useradd runner - -WORKDIR /go/src/github.com/b3log/wide -RUN go build -v - -EXPOSE 7070 diff --git a/conf/wide.go b/conf/wide.go index d6fff24..afdb0e1 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -83,16 +83,13 @@ var Wide *conf // configurations of users. var Users []*User -// Indicates whether runs via Docker. -var Docker bool - // Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json. func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground string, confDocker bool, confUsersWorkspaces string) { + confPlayground string, confUsersWorkspaces string) { // XXX: ugly args list.... initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground, confDocker, confUsersWorkspaces) + confPlayground, confUsersWorkspaces) initUsers() } @@ -156,7 +153,7 @@ func initUsers() { } func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground string, confDocker bool, confUsersWorkspaces string) { + confPlayground string, confUsersWorkspaces string) { bytes, err := ioutil.ReadFile(confPath) if nil != err { logger.Error(err) @@ -237,9 +234,6 @@ func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticSe Wide.Port = confPort } - // Docker flag - Docker = confDocker - // Server Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1) Wide.Server = strings.Replace(Wide.Server, "{Port}", Wide.Port, 1) diff --git a/main.go b/main.go index 0cb0562..4a4b6fd 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,6 @@ func init() { confContext := flag.String("context", "", "this will overwrite Wide.Context if specified") confChannel := flag.String("channel", "", "this will overwrite Wide.Channel if specified") confStat := flag.Bool("stat", false, "whether report statistics periodically") - confDocker := flag.Bool("docker", false, "whether run in a docker container") confPlayground := flag.String("playground", "", "this will overwrite Wide.Playground if specified") confUsersWorkspaces := flag.String("users_workspaces", "", "this will overwrite Wide.UsersWorkspaces if specified") @@ -75,8 +74,7 @@ func init() { i18n.Load() event.Load() - conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, - *confPlayground, *confDocker, *confUsersWorkspaces) + conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, *confPlayground, *confUsersWorkspaces) conf.FixedTimeCheckEnv() session.FixedTimeSave() diff --git a/output/namespace.go b/output/namespace.go deleted file mode 100644 index 5760b93..0000000 --- a/output/namespace.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014-2019, b3log.org & hacpai.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build !linux - -package output - -import ( - "os/exec" -) - -func SetNamespace(cmd *exec.Cmd) { - // do nothing -} diff --git a/output/namespace_linux.go b/output/namespace_linux.go deleted file mode 100644 index b4266eb..0000000 --- a/output/namespace_linux.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2014-2019, b3log.org & hacpai.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package output - -import ( - "os/exec" - "syscall" -) - -func SetNamespace(cmd *exec.Cmd) { - cmd.SysProcAttr = &syscall.SysProcAttr{} - // cmd.SysProcAttr.Cloneflags = syscall.CLONE_NEWUSER /*| syscall.CLONE_NEWNS*/ | syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWIPC /*| syscall.CLONE_NEWNET*/ - cmd.SysProcAttr.Credential = &syscall.Credential{ - Uid: 1001, - Gid: 1001, - } - - // cmd.SysProcAttr.UidMappings = []syscall.SysProcIDMap{{ContainerID: 0, HostID: 1001, Size: 1}} - // cmd.SysProcAttr.GidMappings = []syscall.SysProcIDMap{{ContainerID: 0, HostID: 1001, Size: 1}} -} diff --git a/output/run.go b/output/run.go index 4ab53f2..52610d6 100644 --- a/output/run.go +++ b/output/run.go @@ -24,7 +24,6 @@ import ( "strings" "time" - "github.com/b3log/wide/conf" "github.com/b3log/wide/session" "github.com/b3log/wide/util" ) @@ -64,10 +63,6 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command(filePath) cmd.Dir = curDir - if conf.Docker { - SetNamespace(cmd) - } - stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) diff --git a/playground/run.go b/playground/run.go index 579f7a8..031fbe6 100644 --- a/playground/run.go +++ b/playground/run.go @@ -22,7 +22,6 @@ import ( "os/exec" "time" - "github.com/b3log/wide/conf" "github.com/b3log/wide/output" "github.com/b3log/wide/session" "github.com/b3log/wide/util" @@ -61,10 +60,6 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command(filePath) - if conf.Docker { - output.SetNamespace(cmd) - } - stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) diff --git a/session/sessions.go b/session/sessions.go index a501787..268bee0 100644 --- a/session/sessions.go +++ b/session/sessions.go @@ -39,7 +39,7 @@ import ( "github.com/b3log/wide/event" "github.com/b3log/wide/log" "github.com/b3log/wide/util" - "github.com/go-fsnotify/fsnotify" + "github.com/fsnotify/fsnotify" "github.com/gorilla/sessions" "github.com/gorilla/websocket" )