AdminDev 2.0

Lol sorry! I just spent a long time trying to figure out how to deploy from gitlab and I wanted to save you the time.

Since there were no good resources and its not mentioned on heroku’s docs.

1 Like

Nah man, that’s legit. I forgot how epic and extensible GitLab is. I’ll definitely use that. I love Heroku. I had always used their little CLI to deploy/check my applications.

I think I still pay for the “Hobbyist” tier.

Cool beans. If you want me to create a gitlab profile for you on my box just let me know.

That way you have access to more runner minutes in case you burn them all.

1 Like

Embedded is not really something I am interested in, I need to work on high performance applications, and C++11 and beyond seem to be geared for making those kinds of application still be comfortable to program. Like static_assert and all the new thread and atomic libs in the stl. Lockless code is something I need to get good at.

As for the scrollbar, maybe just render everything in a window sized div or something, and then use JS to translate the whole DOM in it. Kind of like a mask in UIs. To be clear, web is not my strong part, last website I made had 5 links on black background. (Internal stuff)

By the way, really dig the developer atmosphere on these forums, lot’s of interesting stuff to read.

2 Likes

Caching is definitely going to be an on going development. It’s a much taller task than I expected. There are some third party options out there from other Go developers but I’m still limited on implementing it due to my lack of understanding.

Good. Reason to keep learning.

I’m going to finish adding the pages now that I’m happy with the formatting, get error handling in there, and then do the logging. After that I’ll work on get it on a hosting provider. Caching will just be something I continuously work on.

image

5 Likes

Oh yeah, definitely. I have embedded on the brain for some reason lol. I know bidding and transaction systems are a lot of C++ because they need the vroom fast speed of that glorious performance.

Hey, that’s great! I’ll definitely look at doing something like that. I could just cancel it all out and make the home page longer :grin:

Yeah man, for sure! I was brought here because of the crazy Linux shenanigans and the 172TB ZFS server :grin: Stayed for the Nvidia and Intel shilling.

2 Likes

So, on a scale of basic bitch to Rob Pike level genius, what are Gopher thoughts on using output redirection to generate a log file? Lol.

@risk @DevBlox @SgtAwesomesauce @wendell

Doing this right now:

http.ListenAndServe(":5000", handlers.LoggingHandler(os.Stdout, http.DefaultServeMux))

After go build I just use shell to ./main > admindev.log 2> error.log

Maybe I should spend some more time with bufio and ioutil or io.Writer? :thinking:

1 Like

It’s more of college freshman levels.

You should really log direct from the program, or use systemd/docker to handle logging.

1 Like

Most organizations would probably wrap the log package with their own that offers a bunch of functions similar to Printf and Println. Each one of the bunch, would have a different severity and would go to a different Logger instance. You’d then have separate log files for each invocation of the binary by severity, and a garbage collection mechanism to clean them up somehow, and flags to change how verbose you want your logs on stderr to be. This glog thing down there, allows you to change severity by package, which is useful in complex code.

Examples:

When it comes to logging http requests, most large organizations would do it in binary form, so that they can feed those queries to their analytics/billing/… pipelines.

In java land there’s this school of tought you should have a logger per package - I don’t like that idea - sounds like overkill. I do think you should have a source file and line number in your log messages.


… for home use … I’d just change the default logger format to be slightly more verbose and stick with Printf

1 Like

Probably for the best. What I tried earlier didn’t work very well. The server had to stop before all the requests were written to the file. Very bizarre. Again, likely due to a poor understanding of the language :grin:

You’re not the first I’ve read this from. I’ll look into doing that.

Interesting. That sounds like a fun project in its own right.

I appreciate the examples, as well!

Might do this for now, lol. Eventually this is going to be my “brand” so I want to do something a bit more engineering-ey


Thank you both for your responses! You’ve shoved me in the right direction, I think.

Progress. I think this is an overly complex way of doing it but

IT WORKS

Trying to improve my knowledge from older courses and books that I’ve used compared to the Go documentation.

package main

import (
	"github.com/gorilla/handlers"
	"html/template"
	"net/http"
	"os"
	"projects/admindev2/controllers"
)

var tpl *template.Template

func init() {
	tpl = template.Must(template.ParseGlob("templates/*"))
}

func main() {
	c := controllers.NewController(tpl)
	index := http.HandlerFunc(c.Index)
	about := http.HandlerFunc(c.About)
	resume := http.HandlerFunc(c.Resume)
	podcast := http.HandlerFunc(c.Podcast)

	http.Handle("/", loggingFunc(index))
	http.Handle("/about", loggingFunc(about))
	http.Handle("/resume", loggingFunc(resume))
	http.Handle("/podcast", loggingFunc(podcast))
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
	http.ListenAndServe(":5000", nil)
}

func loggingFunc(h http.Handler) http.Handler {
	logFile, err := os.OpenFile("admindev.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0640)
	if err != nil {
		panic(err)
	}
	return handlers.LoggingHandler(logFile, h)
}

Whoops. Forgot the .gitignore so damn log files were being added :stuck_out_tongue_winking_eye:

Latest changes have been pushed though. Will have deployed before Christmas :sunglasses: :tux: :debian: :christmas_tree: :santa: :desktop_computer::computer_mouse:


Added README, LICENSE, and CHANGELOG.

License is GPL 2.0 for

MAXIMUM FANBOYING

Checked a few boxes off the GitLab todo, though.

7 Likes

//TODO

+ Caching
+ Error Handling
+ Deployment
+ Logging
+Finish pages

4 Likes

@Goalkeeper TIME TO DON THE BADGE, HOMIE

LADIES AND GENTLEMEN

image

image

image

https://test.admindev.tech

8 Likes

Omg this is amazingly lightweight on mobile Holy crap

4 Likes

Thanks man. The only JavaScript is for the hamburger menu. Everything else is CSS and Golang.

Gonna end up making the HM CSS as well.

1 Like

I get;
502 bad gateway
Nginx/1.14.0(Ubuntu)

I’m using Firefox on mobile lgg5

1 Like

Works for me.

1 Like

Try it now lol. I was blowing it up with my start/stop script.

Should be online now :wink:

1 Like

Working.

1 Like

Yay. Cool, nah? Nice, shit? Worth it, JS is best?

@SgtAwesomesauce goes for you, too :wink: