1
0
Fork 0

graceful +

404 improved
removed unneeded log
This commit is contained in:
Sangbum Kim 2016-03-13 04:08:54 +09:00
parent 915953b1bd
commit ac5e21d8ac
7 changed files with 49 additions and 35 deletions

View File

@ -1,5 +1,11 @@
$(window).on("backstretch.before", function () {
window.NProgress.start();
});
$(window).on("backstretch.after", function () {
window.NProgress.done();
});
jQuery(document).ready(function () {
var pageImage = "/static/error/404.jpg";
jQuery.backstretch(pageImage);
jQuery.backstretch(pageImage, {speed: 400});
});

View File

@ -2,8 +2,8 @@
{% block body %}
<header>
<nav role="navigation" class="cyan lighten-2">
<div class="nav-wrapper container"><a href="/w/" class="brand-logo title center">mnemonics</a>
<ul id="nav-mobile" class="left">
<div class="nav-wrapper container"><a href="/w/" class="brand-logo title">mnemonics</a>
<ul id="nav-mobile" class="right">
<li><a href="/auth/logout">Sign out</a></li>
</ul>
</div>

View File

@ -27,38 +27,39 @@
<!--Import Google Icon Font-->
<link type="text/css" rel="stylesheet" href="static/normalize.css-3.0.3/normalize.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/static/normalize.css-3.0.3/normalize.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="static/material-design-icons-2.2.0/material-icons.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="static/animate.css-3.5.1/animate.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="static/nprogress-0.2.0/nprogress.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/static/material-design-icons-2.2.0/material-icons.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/static/animate.css-3.5.1/animate.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/static/nprogress-0.2.0/nprogress.css" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="static/materialize-0.97.5/css/materialize.min.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="/static/materialize-0.97.5/css/materialize.min.css" media="screen,projection"/>
<script type="text/javascript" src="static/nprogress-0.2.0/nprogress.js"></script>
<script type="text/javascript" src="/static/nprogress-0.2.0/nprogress.js"></script>
<script>
NProgress.configure({ showSpinner: false });
NProgress.start();
</script>
<script type="text/javascript" src="static/es5-shim-4.5.7/es5-shim.min.js"></script>
<script type="text/javascript" src="static/es5-shim-4.5.7/es5-sham.min.js"></script>
<script type="text/javascript" src="static/json3-3.3.2/json3.min.js"></script>
<script type="text/javascript" src="static/es6-shim-0.35.0/es6-shim.min.js"></script>
<script type="text/javascript" src="static/es6-shim-0.35.0/es6-sham.min.js"></script>
<script type="text/javascript" src="/static/es5-shim-4.5.7/es5-shim.min.js"></script>
<script type="text/javascript" src="/static/es5-shim-4.5.7/es5-sham.min.js"></script>
<script type="text/javascript" src="/static/json3-3.3.2/json3.min.js"></script>
<script type="text/javascript" src="/static/es6-shim-0.35.0/es6-shim.min.js"></script>
<script type="text/javascript" src="/static/es6-shim-0.35.0/es6-sham.min.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="static/html5shiv-3.7.3/html5shiv.min.js"></script>
<script type="text/javascript" src="static/respond-1.4.2/respond.min.js"></script>
<script type="text/javascript" src="static/jquery-1.12.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/html5shiv-3.7.3/html5shiv.min.js"></script>
<script type="text/javascript" src="/static/respond-1.4.2/respond.min.js"></script>
<script type="text/javascript" src="/static/jquery-1.12.1/jquery.min.js"></script>
<![endif]-->
<!--[if (gt IE 8)|!(IE)]><!-->
<script type="text/javascript" src="static/jquery-2.2.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/jquery-2.2.1/jquery.min.js"></script>
<!--<![endif]-->
<script type="text/javascript" src="static/lodash-4.6.1/lodash.min.js"></script>
<script type="text/javascript" src="/static/lodash-4.6.1/lodash.min.js"></script>
<script type="text/javascript" src="static/materialize-0.97.5/js/materialize.min.js"></script>
<script type="text/javascript" src="/static/materialize-0.97.5/js/materialize.min.js"></script>

View File

@ -1,8 +1,8 @@
{% extends "layout/base.html" %}
{% block head_add_header %}
<link type="text/css" rel="stylesheet" href="static/error/404.css" rel="stylesheet">
<script type="text/javascript" src="static/jquery-backstretch-2.0.4/jquery.backstretch.min.js"></script>
<script type="text/javascript" src="static/error/404.js"></script>
<link type="text/css" rel="stylesheet" href="/static/error/404.css" rel="stylesheet">
<script type="text/javascript" src="/static/jquery-backstretch-2.0.4/jquery.backstretch.min.js"></script>
<script type="text/javascript" src="/static/error/404.js"></script>
{% endblock %}
{% block body %}
@ -10,10 +10,12 @@
<section class="section active">
<header class="headline">
<div class="title">
<h1></h1>
<h1>ERR {{statusCode }} : {{ statusMessage }}</h1>
</div>
</header>
<p class="inner"></p>
<p class="inner">
request url {{ path }} is {{ statusMessage }}
</p>
<div class="backtomain">
<p><a href="/">Go back to the homepage</a></p>

18
main.go
View File

@ -23,6 +23,7 @@ import (
"amuz.es/go/mnemonics/route"
"amuz.es/go/mnemonics/util"
"github.com/gin-gonic/gin"
"gopkg.in/tylerb/graceful.v1"
)
var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs")
@ -34,7 +35,7 @@ func main() {
setMaxProcs()
util.InitLogger()
// gin.SetMode(gin.ReleaseMode)
gin.SetMode(gin.ReleaseMode)
r := gin.New()
// middleware settings
r.Use(util.Ginrus(time.RFC3339, true))
@ -42,13 +43,17 @@ func main() {
// not found handler
r.NoRoute(func(c *gin.Context) {
c.HTML(http.StatusOK, "page_404.html", util.Context{})
code := http.StatusNotFound
c.HTML(code, "page_404.html", util.Context{
"statusCode": code,
"statusMessage": http.StatusText(code),
"path": c.Request.URL.Path,
"method": c.Request.Method})
})
// suburl process
path := r.Group("/")
// handlers
path.GET("/api", route.Api)
path.GET("/self", route.Self)
@ -69,7 +74,6 @@ func main() {
c.Redirect(http.StatusMovedPermanently, "/static/favicon/browserconfig.xml")
})
path.GET("/login", route.Login)
path.GET("/", route.Index)
@ -85,7 +89,11 @@ func main() {
util.Log().Error("bootstrapped application")
r.Run() // listen and server on 0.0.0.0:8080
// r.Run() // listen and server on 0.0.0.0:8080
graceful.Run(":8080", 10*time.Second, r)
util.Log().Error("byez")
}
func setMaxProcs() {

View File

@ -16,7 +16,7 @@ var logger = logrus.New()
func InitLogger() {
// logging framework
logger.Level = logrus.ErrorLevel
logger.Level = logrus.DebugLevel
logger.Out = os.Stderr
}
@ -46,7 +46,7 @@ func Ginrus(timeFormat string, utc bool) gin.HandlerFunc {
end = end.UTC()
}
entry := logger.WithFields(logrus.Fields{
entry := Log().WithFields(logrus.Fields{
"status": c.Writer.Status(),
"method": c.Request.Method,
"path": path,

View File

@ -84,9 +84,6 @@ func (m memoryTemplateLoader) Abs(base, name string) string {
}
func (m memoryTemplateLoader) Get(path string) (io.Reader, error) {
Log().Errorf("hello template %s", filepath.Clean(path))
// t := pongo2.Must(p.templateSet.FromFile(path.Join(p.Path, name)))
data, err := m.loaderFunc(filepath.Clean(path))
if err != nil {
if m.fallbackLoader != nil {