Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding simple Go server #281

Merged
merged 1 commit into from
Feb 8, 2015
Merged

Adding simple Go server #281

merged 1 commit into from
Feb 8, 2015

Conversation

tehbilly
Copy link
Contributor

@tehbilly tehbilly commented Feb 8, 2015

Adding a very simple go server to the list. Primarily because when I went to test this out I could just run it via node without changing the listen port in server/index.js. Plus, I'm not really a node guy!

From the server directory you can run the following to have exactly what you have with the node version:

$ go run index.go

However, I'd recommend just building the binary and running that.

$go build && ./server -h
Usage of ./server:
  -listen="0.0.0.0:80": Where the server listens for connections. [interface]:port
  -scripts="./modules/shell_files": Location of shell scripts used to gather stats.
  -static="../": Location of static files.

Can use command line args to specify location of scripts/modules, listen address, and path for static files.

tariqbuilds added a commit that referenced this pull request Feb 8, 2015
@tariqbuilds tariqbuilds merged commit d0754fa into tariqbuilds:master Feb 8, 2015
@tariqbuilds
Copy link
Owner

Thanks. I know nothing about Go but have added your instructions to the README.

@tehbilly
Copy link
Contributor Author

tehbilly commented Feb 8, 2015

I'll be happy to elaborate a little more if you'd like. When I get back to my computer, so I can do it properly.

Seems like a good fit for this project as go can build a statically linked binary, so zero dependencies needed on the box it's running on.

@tehbilly
Copy link
Contributor Author

tehbilly commented Feb 8, 2015

Alright, so, as promised I'm elaborating! Go is a language that compiles down to statically linked executables, and the stdlib includes some very useful packages for creating servers. In this case, it seems like a perfect fit as you're trying to create a simple and low-overhead application that does one thing and does it well.

With zero optimizations, compiling a 32-bit version of the index.go file I submitted creates a 4.8MB executable that consumes about 3.3MiB of RAM on my home server. A couple of extra flags brings that down to a 3.3MB file that consumes 3.2MiB of RAM. Pretty much as easy peasy as you can get for a completely standalone server that can serve up your entire application.

Throw in a few init scripts to help manage it as a service and you've got a completely self-contained service that will run on literally any linux machine with nothing else to install.

@baptistedonaux
Copy link

Great feature ! Thank @tehbilly

@icemagno
Copy link

icemagno commented Feb 6, 2018

Hi.

I'm getting this error from last version and your sample command line:

./server -listen="0.0.0.0:80" -scripts="./modules/shell_files" -static="../"
flag provided but not defined: -scripts
Usage of ./server:
  -listen string
        Where the server listens for connections. [interface]:port (default "0.0.0.0:80")
  -static string
        Location of static files. (default "../")

@tehbilly
Copy link
Contributor Author

tehbilly commented Feb 6, 2018

It looks like that's no longer needed, try running it without that flag and it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants