Problem with deploying Go app to Google App Engine - go

I developed my first Go app and decided to deploy it to Google Cloud (App Engine). It was running perfectly fine locally but I run into a few issues during the deployment (I'm using Cloud SDK).
I eventually got to the point where I was able to successfully deploy it to GCP but I keep getting
when trying to access the app.
I cannot do any local development either because every time I run go run main.go, go get -u, go build I'm getting:
go: finding module for package github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql
go: found github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql in github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20200513164142-a9864b03c326
go: github.com/GoogleCloudPlatform/cloudsql-proxy#v0.0.0-20200513164142-a9864b03c326 requires
cloud.google.com/go#v0.56.0 requires
cloud.google.com/go/bigquery#v1.4.0 requires
cloud.google.com/go#v0.52.0 requires
cloud.google.com/go/bigquery#v1.0.1/go.mod: verifying module: cloud.google.com/go/bigquery#v1.0.1/go.mod: cannot authenticate record data in server response
My go.mod file looks like this:
module swanson
go 1.14
require github.com/gorilla/mux v1.7.4
and this is the structure of my app (main.go, models, and router are 3 different packages):
I'm new to Go development and never deployed a Go app to GCP so feeling quite lost, any help would be much appreciated.

I have tried deploying a go application in app engine and also running it locally and both worked.
I used
this application
in github, which you can clone with the command:
git clone https://github.com/GoogleCloudPlatform/golang-samples
The command I have used for running the application locally is :
go run helloworld.go
And the command returned the following message:
2020/05/22 11:34:16 Defaulting to port 8080
2020/05/22 11:34:16 Listening on port 8080
Then in the Cloud Shell I have opened the web preview in the port 8080 and it was working as expected.
For more information about the deployment, you can check this documentation.

Related

Deploy NodeJS application without git

I'm trying to start on Heroku by deploying a NodeJS application I've written.
How do I deploy a NodeJS project to Heroku without github, using only the traditional FTP way?
As far as i know you can not deploy to Heroku using FTP. Navigate to Heroku's official deployment documentation

How can I see the changes I make to a Go app running in Heroku local?

I admit I'm a GoLang newbie. In an attempt to learn Go, I developed an app about a year ago (based on the Heroku Getting started repository) and deployed it to Heroku. I used the heroku local server to develop it locally and deployed it successfully. Now I want to make some changes but I don't have the original source, so I have cloned the app from the Heroku repository.
I have got it running locally with the following steps:
export GOPATH=~/project_path
export GOBIN=$GOPATH/bin
go get
go install
heroku local
So far, so good. The problem is that when I make a simple change to the code in main.go, it doesn't show up in the browser. I've tried running go install and restarting the server after making the change but it makes no difference.
I've noticed that the file name in the Procfile is now incorrect (go-getting-started instead of the name of my project folder) but the server still runs and changing the name doesn't make any difference, locally at least. Same goes for the Dockerfile.
What am I doing wrong please?
Every time you make a change to a Go file in the project you need to run go install and stop and restart the heroku local server.
You might want to just run the server yourself with PORT=5000 go run main.go so that you only have to restart one thing. Or you can check out something like https://github.com/pilu/fresh which will listen to filesystem changes and restart your server for you.

How can I deploy a shiny app to Heroku

I have a shiny app and want to deploy it to Heroku. I tried to follow the steps as mentioned in:
https://github.com/btubbs/heroku-buildpack-shiny
I created a git Git repository and put the R files into it. Then, I created an app in heroku and tell Heroku to use a custom buildpack for my app. But, I was not be able to enable Heroku websockets support.
Error is:
Couldn't find that feature.
I can't figure out how to deal with this problem. Is there any other way to deploy the shiny app to Heroku?
Have you seen https://github.com/virtualstaticvoid/heroku-docker-r?
Check out the example shiny app too. To specify additional dependencies, you can still use init.R.
To deploy using Docker, you might have to move your current Heroku app to a container stack. This can be done with the heroku stack:set CLI command:
$ heroku stack:set container
Here's a minimal example. Basically:
Create run.R file with the following
library(shiny)
port <- Sys.getenv('PORT')
shiny::runApp(
appDir = getwd(),
host = '0.0.0.0',
port = as.numeric(port)
)
Commit to git
Create a new heroku app with
heroku create --buildpack https://github.com/virtualstaticvoid/heroku-buildpack-r.git
git push heroku master
That's all there is to it.
Another way would be to deploy using Docker. I am not an expert, but it took me a couple of days to deploy an app using this soluation. Many tutorials exist and could bring you to achieving this.

Why cant I run my rails app using heroku locally?

I am working on a new project that is using heroku, I get this error when I try to run the app locally:
Moped::Errors::ConnectionFailure at / Could not connect to any secondary or primary nodes for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]>
and I think it has something to do with Heroku because if I type
$ heroku info,
i get this error:
! You do not have access to the app disrupt.
I can't find this error anywhere on the internet, on any forums and there is nothing in the Heroku documentation.
The error normally just means that the MongoDB server is not running locally. Try starting it up by running mongod. Otherwise check you mongoid.yml to see how the development and test environments are set up to connect to MongoDB.
The other error that you get from heroku looks like a separate issue. As tolgap suggests you may just not be authenticated with heroku.

Deploying Django to Heroku using a Windows machine (Production server NOT development server)

I use a Windows machine and have a Django project that I have successfully deployed to Heroku, albeit using the development server. To use a production server Heroku seems to require 'Gunicorn' which does not run on Windows.
This is not good for testing locally before deploying. Does anyone know of any way to get around this? Perhaps some way to use a different server on Heroku?
I found a solution that may help when deploying to heroku using a Windows machine. Here is what I do:
Use the development server locally with:
python manage.py runserver
Install and add 'Gunicorn' to your installed apps in settings.py.
Add a process file in the root directory that tells heroku to use the Gunicorn server. This is a file called 'Procfile' with the following code:
web: python kalail/manage.py run_gunicorn --bind=0.0.0.0:$PORT
This way you test using the development server, while heroku uses the Gunicorn server. Make sure you set up serving static files(css/js/imgs) after this, because only the development server automatically serves static files, and the Gunicorn server will need to be configured to do so.
You can run the development server locally quite easily:
> python manage.py runserver
All you need to do is specify path to wsgi script from root directory:
$web: gunicorn hellodjango.wsgi

Resources