Merge branch 'master' into next
This commit is contained in:
@@ -57,7 +57,7 @@ If you want to make changes to the `dind` image being used, make your changes to
|
|||||||
### How can I connect to a published port from the outside world?
|
### How can I connect to a published port from the outside world?
|
||||||
|
|
||||||
|
|
||||||
If you need to access your services from outside, use the following URL pattern `http://pwd<underscore_ip>-<port>.<host#>.labs.play-with-docker.com` (i.e: http://pwd10_2_135_3-80.host3.labs.play-with-docker.com/).
|
If you need to access your services from outside, use the following URL pattern `http://pwd<hyphen-ip>-<port>.<host#>.labs.play-with-docker.com` (i.e: http://pwd10-2-135-3-80.host3.labs.play-with-docker.com/).
|
||||||
|
|
||||||
### Why is PWD running in ports 80 and 443?, Can I change that?.
|
### Why is PWD running in ports 80 and 443?, Can I change that?.
|
||||||
|
|
||||||
|
|||||||
@@ -340,18 +340,18 @@ func (d *docker) CreateContainer(opts CreateContainerOpts) (err error) {
|
|||||||
container, err := d.c.ContainerCreate(context.Background(), cf, h, networkConf, opts.ContainerName)
|
container, err := d.c.ContainerCreate(context.Background(), cf, h, networkConf, opts.ContainerName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if client.IsErrNotFound(err) {
|
//if client.IsErrImageNotFound(err) {
|
||||||
log.Printf("Unable to find image '%s' locally\n", opts.Image)
|
//log.Printf("Unable to find image '%s' locally\n", opts.Image)
|
||||||
if err = d.pullImage(context.Background(), opts.Image); err != nil {
|
//if err = d.pullImage(context.Background(), opts.Image); err != nil {
|
||||||
return
|
//return "", err
|
||||||
}
|
//}
|
||||||
container, err = d.c.ContainerCreate(context.Background(), cf, h, networkConf, opts.ContainerName)
|
//container, err = d.c.ContainerCreate(context.Background(), cf, h, networkConf, opts.ContainerName)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
//return "", err
|
||||||
}
|
//}
|
||||||
} else {
|
//} else {
|
||||||
return
|
return err
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
//connect remaining networks if there are any
|
//connect remaining networks if there are any
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ RUN mkdir /etc/bash_completion.d \
|
|||||||
RUN rm /sbin/modprobe && echo '#!/bin/true' >/sbin/modprobe && chmod +x /sbin/modprobe
|
RUN rm /sbin/modprobe && echo '#!/bin/true' >/sbin/modprobe && chmod +x /sbin/modprobe
|
||||||
|
|
||||||
# Install a nice vimrc file and prompt (by soulshake)
|
# Install a nice vimrc file and prompt (by soulshake)
|
||||||
COPY ["docker-prompt","/usr/local/bin/"]
|
COPY ["docker-prompt","sudo","/usr/local/bin/"]
|
||||||
COPY [".vimrc",".profile", ".inputrc", ".gitconfig", "./root/"]
|
COPY [".vimrc",".profile", ".inputrc", ".gitconfig", "./root/"]
|
||||||
COPY ["motd", "/etc/motd"]
|
COPY ["motd", "/etc/motd"]
|
||||||
COPY ["daemon.json", "/etc/docker/"]
|
COPY ["daemon.json", "/etc/docker/"]
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ func Register(extend HandlerExtender) {
|
|||||||
IdleTimeout: 30 * time.Second,
|
IdleTimeout: 30 * time.Second,
|
||||||
ReadHeaderTimeout: 5 * time.Second,
|
ReadHeaderTimeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.UseLetsEncrypt {
|
if config.UseLetsEncrypt {
|
||||||
certManager := autocert.Manager{
|
certManager := autocert.Manager{
|
||||||
Prompt: autocert.AcceptTOS,
|
Prompt: autocert.AcceptTOS,
|
||||||
@@ -127,7 +128,6 @@ func Register(extend HandlerExtender) {
|
|||||||
log.Println("Listening on port " + config.PortNumber)
|
log.Println("Listening on port " + config.PortNumber)
|
||||||
log.Fatal(httpServer.ListenAndServe())
|
log.Fatal(httpServer.ListenAndServe())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterEvents(s *socketio.Server) {
|
func RegisterEvents(s *socketio.Server) {
|
||||||
|
|||||||
@@ -1,6 +1,41 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"context"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/client"
|
||||||
|
"github.com/play-with-docker/play-with-docker/config"
|
||||||
|
"github.com/shirou/gopsutil/load"
|
||||||
|
)
|
||||||
|
|
||||||
func Ping(rw http.ResponseWriter, req *http.Request) {
|
func Ping(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
// Get system load average of the last 5 minutes and compare it against a threashold.
|
||||||
|
|
||||||
|
c, err := client.NewEnvClient()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
rw.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if _, err := c.Info(ctx); err != nil && err == context.DeadlineExceeded {
|
||||||
|
log.Printf("Docker info took to long to respond\n")
|
||||||
|
rw.WriteHeader(http.StatusGatewayTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
a, err := load.Avg()
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Cannot get system load average!", err)
|
||||||
|
} else {
|
||||||
|
if a.Load5 > config.MaxLoadAvg {
|
||||||
|
log.Printf("System load average is too high [%f]\n", a.Load5)
|
||||||
|
rw.WriteHeader(http.StatusInsufficientStorage)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ func WS(so socketio.Socket) {
|
|||||||
session := core.SessionGet(sessionId)
|
session := core.SessionGet(sessionId)
|
||||||
if session == nil {
|
if session == nil {
|
||||||
log.Printf("Session with id [%s] does not exist!\n", sessionId)
|
log.Printf("Session with id [%s] does not exist!\n", sessionId)
|
||||||
|
so.Disconnect()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,7 @@
|
|||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
});
|
});
|
||||||
$scope.isAlive = false;
|
$scope.isAlive = false;
|
||||||
|
socket.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('instance new', function(name, ip, hostname, proxyHost) {
|
socket.on('instance new', function(name, ip, hostname, proxyHost) {
|
||||||
|
|||||||
Reference in New Issue
Block a user