Passionate Engineer
Passionate Engineer

Reputation: 10412

How to deploy Go program from windows to CentOS server

I have a Go package running on Windows and is working fine but now I'm at a stage where I would like to test this on production CentOS 6.5 server.

What is the best practice to deploy this from Windows to CentOS?

Would I have to use my Git repo to distribute to Linux operating system, compile then deploy the binary to the server?

Also I have multiple files, so I would imagine go build *.go would suffice or are there better options for doing compilation?

Upvotes: 0

Views: 1275

Answers (1)

Caleb
Caleb

Reputation: 9458

What is the best practice to deploy this from Windows to CentOS?

As far as best practices go I would recommend using continuous integration. You can setup jenkins, or there are some cloud options out there: codeship.io, travis-ci.org, drone.io, wercker.com, ... Some of them have free plans available.

Basically you'd commit your code to git and push that out to Github (or Bitbucket if you want free private repos). The continuous integration server will be notified whenever you push out changes, and will build, test and create a release tar archive of your project. You can then take this resulting tar and download it to your CentOS box. In 6.5 you'll need to create an init.d script to keep your program up and running. You can see an example here (the system v script).

CentoOS 7 uses systemd now which would be slightly easier to setup.

Taking this one step further it's also possible to setup continuos deployment, in which the download, extraction and installation can also be automated. Depending on your project it may or may not make sense to set up continuous deployment. (Auto-pushing to production might be a little too automatic) You can find an example in wercker here.

Although there is an an up-front cost to setting up continuous integration if this is a project that other people will contribute too, or one that you intend to work on long-term, the cost will definitely be worth it. (Future you will be greatful when you come back to this project 6 months from now, change 1 line of code, and don't have to remember all the manual steps it took to deploy)

Upvotes: 1

Related Questions