GithubHelp home page GithubHelp logo

openshift-go-cart's Introduction

OpenShift Go Cartridge

Runs Go on OpenShift using downloadable cartridge support. To install to OpenShift from the CLI (you'll need version 1.9 or later of rhc), run:

rhc create-app mygo https://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-go-cart

Once the app is created, you'll need to create and add a ".godir" file in your repo to tell the cartridge what the package of your Go code is. A typical .godir file might contain:

github.com/smarterclayton/goexample

which would tell OpenShift to place all of the files in the root of the Git repository inside of the github.com/smarterclayton/goexample package prior to compilation.

When you push code to the repo, the cart will compile your package into $OPENSHIFT_REPO_DIR/bin/, with the last segment of the .godir being the name of the executable. For the above .godir, your executable will be:

$OPENSHIFT_REPO_DIR/bin/goexample

If you want to serve web requests (vs. running in the background), you'll need to listen on the ip address and port that OpenShift allocates - those are available as OPENSHIFT_GO_IP and OPENSHIFT_GO_PORT in the environment.

The repository contains a sample go file which will print "hello, world" when someone hits your web application - see web.go.

Any log output will be generated to $OPENSHIFT_GO_LOG_DIR.

To provide your own custom GOPATH directory, add a ".gopath" file to the root of your Git repo with the desired GOPATH location, relative to the $OPENSHIFT_HOMEDIR directory. Example of a .gopath file content: app-root/data/mygopath. The specified location will be additive to the existing GOPATH provided by the cartridge as the first path declared in GOPATH (notice the GOPATH spec defines that "Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list").

How it Works

When you push code to your repo, a Git postreceive hook runs and invokes the bin/compile script. This attempts to download a Go environment for you into $OPENSHIFT_GO_DIR/cache. Once the environment is setup, the cart runs

go get -tags openshift ./...

on a working copy of your source. The main file that you run will have access to two environment variables, $OPENSHIFT_GO_IP and $OPENSHIFT_GO_PORT, which contain the internal address you must listen on to receive HTTP requests to your application.

Credits

The bin/compile script is based on the Heroku Go buildpack, adapted for OpenShift cartridges.

openshift-go-cart's People

Contributors

bparees avatar fabianofranz avatar kechap avatar marcusaram avatar mignev avatar smarterclayton avatar smerrill avatar vbatts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openshift-go-cart's Issues

Websocket port 443 for WSS://

What can we do in go to be able to accept port 443 requests when to load balancer will forward all data at the OPENSHIFT_GO_PORT (8080). Most of the websocket libs will reject if it detects that the client doesn't come in at port 443.

src dir structure for compatibility of openshift

myfirstapp/web.go
myfirstapp/lib/func1.go

in my main web.go if I do an import "myfirstapp/lib" i can access to functions inside func1.go . However, when I deploy to openshift it doesn't compile right. What should I do?

Go binary deployment without git

Is it possible to deploy only golang compiled app binary (built somewhere) using this cartridge? I don't want git support and don't want to compile app source in openshift box.

Unable to change .godir

The every time i push the code .godir value github.com/smarterclayton/sample reverting back even after editing in the file in repo.
please give me solution.
Thank you.

Can't run my web service

First of all, thank you for the great work :)

I'm trying to run a go web service on Openshift Origin (local environment). When creating the application, I always receive an error:

The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 54cf69e6653e8ab21500005f -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c5,c114' /bin/sh -c \"gear postreceive --init >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255 .Last 10 kB of build output: Warning: Application 'web' server exists without a pid file. Use force-stop to kill. Repairing links for 1 deployments Building git ref 'master', commit 96532e0 First download, may take several minutes -----> Installing Go 1.4.1... done Installing Virtualenv... done Installing Mercurial... done Installing Bazaar... done -----> Running: go get -tags openshift ./... # github.com/ory-platform/uuid-server ./server.go:6: imported and not used: "flag" An error occurred executing 'gear postreceive' (exit code: 2) Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/54cf69e6653e8ab21500005f/go For more details about the problem, try running the command again with the '--trace' option.

Here are my settings:

goerror

The repository I'm using is: https://github.com/ory-platform/uuid-server.git

I have added the go cartridge to origin (I want every user to see the go cartridge when creating an application!) by doing:

> oo-admin-ctl-cartridge -c import -u https://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-go-cart
> oo-admin-ctl-cartridge -c import-node -u https://cartreflect-claytondev.rhcloud.com/reflect?github=smarterclayton/openshift-go-cart
> oo-admin-ctl-cartridge -c activate --ids smarterclayton-go-1.4.1

I've used both import and import-node, because I was unsure which of those is the right one for this task.

When I leave the repository field empty, the application gets created, but I don't understand how I can get my application running.

ping @tacurran

Plea for a support for a Go version 1.5 on OpenShift

@smarterclayton I love Open Shift Online by RadHat as it enables me to use SqLite or even BoltDB with GoLang and yet I am not burdened with full VPS and related administration. Now when can we expect support for GoLang 1.5 that was just freshly released? Any road-map would be greatly appreciated.

unrecognized import path

Hello,

I have a project with the following configuration :
/
web.go -> with import "mylib/mypackage"
src/mylib/package

Whatever the configuration i put in .godir or .gopath (mylib or ./mylib, ...)
the compilation fail because of "unrecognized import path"

I really don't understand the way you copy the files before the compilation ...

I build successufly my project on my computer, and everything is fine, but Openshift doesn't support the conventionnal GOPATH stuff apparently :/.

How can I call my own package on openshift ?
Is there a magic trick ? or we have to put the stuff on github so it's downloaded whit the go get ? (That lib contains some configuration and DB password so ...).

Thanks.

update script

Hi,
Thanks for your excellent job on this cartridge.
How should we upgrade our gears (scalable ones in my case), for example: from go-1.4 to go-1.4.1 as there's no upgrade script in /bin ?
Thanks for your help.

PORT and HOST are not set on new gears

Hi,

Sorry for the noob issue, but I'm playing with openshift, and I'm stuck on scaling.
With a regular app (not scalable), everything is fine, and the app starts as expected.
With a scalable app, the first gear will start correctly, but not the others.
I have managed to ssh on the failing gear, and I can see some vars are not set correctly:

[...]> export | grep PORT
declare -x OPENSHIFT_GO_PORT="8080"
declare -x OPENSHIFT_GO_PROXY_PORT="46411"

And on the first gear:

[...]> export | grep PORT
declare -x OPENSHIFT_GO_PORT="8080"
declare -x OPENSHIFT_GO_PROXY_PORT="39846"
declare -x OPENSHIFT_HAPROXY_PORT="8080"
declare -x OPENSHIFT_HAPROXY_PROXY_PORT="39847"
declare -x OPENSHIFT_HAPROXY_STATUS_PORT="8080"
declare -x PORT="8080"

My app is starting on a default port (3000) and haproxy can't access it of course.
Thanks

HTTP vs HTTPS?

Hello,
I'm successfully testing this gear, binding just like the sample with

bind := fmt.Sprintf("%s:%s", os.Getenv("OPENSHIFT_GO_IP"), os.Getenv("OPENSHIFT_GO_PORT"))

I see my webapp responds both on HTTP and HTTPS this way. Is it possible for me to understand, in my handlers, if the request comes over the one or the other?

I tried monitoring http.Request.TLS, but it's always nil - also for HTTPS requests.
I don't think that's because I'm using a free gear, with a shared certificate, is it?

Thanks for any help,
al.

only for http requests ?

Hi,

i read in your doc its about http requests, is it totally restricted to it or can i run a different kind of service ? (i m looking to test some dht/bep44 app)

thanks

Go 1.6 upgrade

Can you please upgrade the cartridge to support go 1.6?

Cartridge removes the .openshift directory on install

I have been working with the go cartridge and it is excellent, thank you for the work. I think I have found a problem where on the install of an application the .openshift directory gets removed from $OPENSHIFT_REPO_DIR

I have setup a cron directory in .openshift and installed the cron cartridge and created the directories and git pushed to openshift:

screen shot 2014-05-18 at 10 03 18

When I then go into the $OPENSHIFT_REPO_DIR from where the cron files are run there is no .openshift directory:

screen shot 2014-05-18 at 10 09 02

I think line 91 in compile might be the offending line:

rm -rf $build/.openshift # this removes the constructed $GOPATH

But I am unsure of what further effect this might have. I will have a go and fix it but thought some one might have a quick solution to the bug.

Failed to run Go application

I have created a basic go rest webservice here. I tested it in my local linux box on go 1.2. The application works fine. But when I uploaded the same app in openshift and tried to run it after compilation in go 1.1 it fails to run as expected. It just exits from the main method and stops instead of listening to the port specified.

What is wrong with the go cartridge in openshift? Is it broken or am I missing something here?

Port in use with Web Load Balancer

When I create an application with Web Load Balancer, the application does not start by complaining that the port 8080 is in use. It works well when Web Load Balancer is not selected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.