I'm following the directions provided by WebPutty's github page to put my own fork of WebPutty up on GAE. It runs fine locally. I wasn't able to run "fab deploy" successfully (got error "no module named appengine.api"), so instead tried to put it up on GAE by just doing appcfg.py update. Unfortunately, this gives me the following error when I access the URL: "No module named flask".
Would love any insight/assistance as to how to resolve.
I don't know if you already did this, but to work with GAE and python you need have the dependent packages inside your project, as Flask, Werkzeug, Jinja2 and SimpleJson.
Here there is the script I use on my project:
# set the path of your project
PATH_PROJECT=~/Development/python/projects/scheduler-i-sweated-yesterday
cd ~/Downloads
#
# Installing Flask: https://github.com/mitsuhiko/flask/tags
#
wget https://github.com/mitsuhiko/flask/archive/0.9.zip
unzip 0.9.zip
mv flask-0.9/flask $PATH_PROJECT/flask
#
# Installing Werkzeug: https://github.com/mitsuhiko/werkzeug/tags
#
wget https://github.com/mitsuhiko/werkzeug/archive/0.8.3.zip
unzip 0.8.3.zip
mv werkzeug-0.8.3/werkzeug $PATH_PROJECT/werkzeug
#
# Installing Jinja2: https://github.com/mitsuhiko/jinja2/tags
#
wget https://github.com/mitsuhiko/jinja2/archive/2.6.zip
unzip 2.6.zip
mv jinja2-2.6/jinja2 $PATH_PROJECT/jinja2
#
# Installing SimpleJson: https://github.com/simplejson/simplejson/tags
#
wget https://github.com/simplejson/simplejson/archive/v3.0.5.zip
unzip v3.0.5.zip
mv simplejson-3.0.5/simplejson $PATH_PROJECT/simplejson
Save as install_packages_dependencies.sh and after that run in the shell:
bash install_packages_dependencies.sh
I had this exact same problem. I'm on Mac OS X Lion. I fixed the problem by moving the GoogleAppEngineLauncher.app from my desktop to the application directory. fabfile.py looks for the app there. After I moved the app to where fabfile.py was looking for it, I ran "fab deploy" and everything worked perfectly. I hope this helps.
Related
I have a react website that I host on AWS. I have created code pipeline in AWS that connects to my github, which automatically builds the projects using codeBuild and deploys it to S3.
I'm trying to add react-snap to the project. It works well locally but when I try to build it in codebuild I get this error
Error: Failed to launch chrome!
/codebuild/output/src159566889/src/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/codebuild/output/src159566889/src/node_modules/puppeteer/lib/Launcher.js:348:14)
at Interface.<anonymous> (/codebuild/output/src159566889/src/node_modules/puppeteer/lib/Launcher.js:337:50)
at Interface.emit (events.js:326:22)
at Interface.close (readline.js:416:8)
at Socket.onend (readline.js:194:10)
at Socket.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
error Command failed with exit code 1.
I have tried to google it but I didn't find anything specific to codebuild and react-snap. I have found similar questions in regards to running chrome on codebuild but they related to different environments like angular and so I wasn't able to copy their solutions.
This is what my current buildspec.yaml file looks like
version: 0.2
env:
variables:
S3_BUCKET: "xyz"
STAGE: "beta"
phases:
install:
commands:
- yarn install
build:
commands:
- echo "Building for $STAGE"
- yarn build
- sam package --template-file cloudformation/Root.json --s3-bucket ${S3_BUCKET} --s3-prefix WebsiteCF/${CODEBUILD_RESOLVED_SOURCE_VERSION} --output-template-file build/packaged-template.yaml
artifacts:
files:
- '**/*'
base-directory: 'build'
Based on the instruction on the link provided by the error, I tried adding this but it didn't work
install:
commands:
- PYTHON=python2 amazon-linux-extras install epel -y
- yum install -y chromium
- yarn install
I managed to get it working using these steps:
Make sure your AWS code builder is using aws/codebuild/standard:5.0
Go t AWS code builder -> Edit -> Environment -> Override image
Create a addArgs.sh file to your project with this content
# modifies react-snap defaultOptions to add the --no-sandbox and --disable-setuid-sandbox flags so that puppeteer/chromium can run in the codebuild standard image
sed -i "s/puppeteerArgs: \[\],/puppeteerArgs: \[\"--no-sandbox\", \"--disable-setuid-sandbox\"\],/" ./node_modules/react-snap/index.js
echo changed arguments in react-snap
To your buildspec.yml file, add these lines to the install stage
# Install chrome headless
- apt-get -y update
- apt-get --assume-yes install chromium-browser
- sh ./addArgs.sh # run custom script to change options on react-snap to make it work
I found the answer from here - https://github.com/stereobooster/react-snap/issues/122
i have an problem with appengine and go112.
i can´t deploy without an error to the cloud:
2019/09/04 14:36:10 Copying /workspace/_gopath/src/mysql to /tmp/staging/srv/gopath/src/mysql
2019/09/04 14:36:10 Your app is not on your GOPATH, this build may fail.
2019/09/04 14:36:10 Building from Go source in /tmp/staging/srv, with main package at ./...
2019/09/04 14:36:10 Building /tmp/staging/srv, saving to /tmp/staging/usr/local/bin/start
2019/09/04 14:36:11 Wrote build output to /builder/outputs/output
2019/09/04 14:36:11 Failed to build app: Your app is not on your GOPATH, please move it there and try again.
building app with command '[go build -o /tmp/staging/usr/local/bin/start ./...]', env '[PATH=/go/bin:/usr/local/go/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=89fd1b631b04 HOME=/builder/home BUILDER_OUTPUT=/builder/outputs DEBIAN_FRONTEND=noninteractive GOROOT=/usr/local/go/ GOPATH=/go GOPATH=/tmp/staging/srv/gopath]': err=exit status 1, out=go build: cannot use -o with multiple packages.
PS C:\gopath\projects\gp-sql>
My project is under the gopath and i tried serveral modifications of it.
output of "go env"
set GOPATH=C:\gopath
set GOROOT=C:\golang
Anybody an idea what i´m missing?
Your project folder should be in "\src", not "\projects".
For standard Go setups, whatever your basic GOPATH environment variable points to, inside that folder should be a structure like:
bin/
# command executables
src/
github.com/golang/example/
.git/ # Git repository metadata
hello/
hello.go # command source
myproject1/
main.go # command source
main_test.go # test source
app.yaml # google cloud configuration
myproject2/
beepboop.go # command source
stringutil/
reverse.go # package source
reverse_test.go # test source
golang.org/x/image/
.git/ # Git repository metadata
bmp/
reader.go # package source
writer.go # package source
... (many more repositories and packages omitted) ...
This is a documented difference in the new version of go. Following this documentation should do the trick
If this doesn't work for you try creating a new GPATH folder, modify the Env Variable to make this folder you new gopath and put your application in the root of that folder.
I'm running automated builds on CircleCI of a react app. And a step involves running npm run build and then copying to an S3 bucket to host builds. What I'm seeing is that s3cmd is copying *.css files to my S3 bucket with the wrong MIME type (text/plain) and that when served up this is causing the web application to not work.
I'm running s3cmd version 2.0.2 both locally on my mac (homebrew) and on CircleCI (running inside of a nodejs container, installed via installing pip, setuptools, and installing s3cmd via sudo python setup.py install).
When running locally on my mac, I deploy my app like this:
s3cmd put --recursive -P dist/* s3://$BUCKET
On CircleCI -- I run the exact same command. I have also tried the --guess-mime-type option which seems to have no effect.
The way I determine the MIME type is wrong is like this:
$ s3cmd info s3://$BUCKET/$DEPLOY/static/css/main.a0a90112.css | grep MIME
MIME type: text/plain
When I run the same command after having deployed from my local machine, I get a CSS MIME type.
So what am I doing wrong?
I had this problem with s3cmd rsync (not s3cmd put as in the question) setting files with extension .css as mime type type text/plain. Thanks to the comment above and in it's linked issues, this fixed it:
s3cmd sync --no-mime-magic --guess-mime-type ...
Using
s3 put ...
You can upload all your files excluding css with
--guess-mime-type --no-mime-magic --exclude "*.css"
And then you upload only css with forced mime-type
-m "text/css" --exclude "*" --include "*.css"
I'm having trouble setting up Go App engine on osX. Should the google-cloud-sdk path be in GOROOT or GOPATH?
I put the google-cloud-sdk in /usr/local
It looks like there is source code in: goroot/
/usr/local/google-cloud-sdk/platform/google_appengine/goroot/
go env
GOPATH="/usr/local/google-cloud-sdk/platform/google_appengine/goroot"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
$ go get
package google.golang.org/appengine: cannot download, /usr/local/google-cloud-sdk/platform/google_appengine/goroot is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
package google.golang.org/appengine/datastore: cannot download, /usr/local/google-cloud-sdk/platform/google_appengine/goroot is a GOROOT, not a GOPATH. For more details see: 'go help gopath'
When I attempted to change the PATH to include /src:
GOPATH="/usr/local/google-cloud-sdk/platform/google_appengine/goroot/src"
$ go get
package google.golang.org/appengine: mkdir /usr/local/google-cloud-sdk/platform/google_appengine/goroot/src/src: permission denied
package google.golang.org/appengine/datastore: cannot find package "google.golang.org/appengine/datastore" in any of:
/usr/local/go/src/google.golang.org/appengine/datastore (from $GOROOT)
/usr/local/google-cloud-sdk/platform/google_appengine/goroot/src/src/google.golang.org/appengine/datastore (from $GOPATH)
I appended the path to google-cloud-sdk to GOROOT:
export GOROOT="/usr/local/go/:/usr/local/google-cloud-sdk/platform/google_appengine/goroot"
GO doesn't seem to like multiple paths in GOROOT:
$ go get
go: cannot find GOROOT directory: /usr/local/go/:/usr/local/google-cloud-sdk/platform/google_appengine/goroot
I did run the ./install.sh script after I copied the source to /usr/local
The additional PATH's added did not fix the errors I was having.
I saw this answer: Test cases for go and appengine
But it's from 5 years ago and it seems clunky/hacky. It would seem in 5 years there would be a more elegant solution that copying individual directories and creating symlinks.
EDIT **********************
mv /usr/local/google-cloud-sdk/ ~/go/ then deleted GOPATH and GOROOT from .bash_profile
I then ran ./install.sh
I attempted to run 'go get':
$ go get
go install: no install location for directory /Users/Bryan/work/gocode/skincarereview outside GOPATH
Since that failed, I added the path to the working directory of code AND appended the path to google-cloud-sdk to PATH:
export GOPATH = "/Users/Bryan/work/gocode/skincarereview"
export PATH=$HOME/google-cloud-sdk:$PATH
go get get failed with the same message:
$ go get
go install: no install location for directory /Users/Bryan/work/gocode/skincarereview outside GOPATH
For more details see: 'go help gopath'
It goes in neither $GOROOT or $GOPATH. Just unpack it to your $HOME directory and run the installer. If necessary, add it to your $PATH by adding this line to your .bash_profile.
export PATH=$HOME/google-cloud-sdk:$PATH
Make sure you grab the golang SDK as well with gcloud components install app-engine-go https://cloud.google.com/appengine/docs/standard/go/download
DO NOT change your path to include the src dir in google-cloud-sdk/platform/google_appengine/goroot/src. That will break things. You leave your $GOPATH to be your normal installation. Using the App Engine SDK for Go automatically uses the sources in that dir without any manipulation.
Also, you should NEVER MANUALLY change $GOROOT unless you plan on compiling a new Go version from source (as in a new version of the language). It will automatically set the proper $GOROOT for you. https://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really
If your install is messed up beyond reason (happened to me once), just remove the cloud SDK and any references to it in your $PATH. Also completely uninstall the regular Go installation. Then start from scratch. Install Go, unpack google-cloud-sdk, run installer (add to $PATH if needed), gcloud components install app-engine-go. Voila.
When developing for App Engine, your go sources go into your REGULAR $GOPATH. They DO NOT go in google-cloud-sdk/... anywhere. To run the dev_appserver locally, run dev_appserver.py [path-to-source] where the given path contains your code and the app.yaml. I usually cd in to my project path (e.g. cd $HOME/go/src/myproject) and run with dev_appserver.py ./. https://cloud.google.com/appengine/docs/standard/go/tools/using-local-server
Deployment is covered here. https://cloud.google.com/appengine/docs/standard/go/tools/uploadinganapp
EDIT: Folder structure.
$GOPATH = $HOME/go
Location for google-cloud-sdk folder
I am getting the following error message in the heroku logs when trying to access the application from the browser:
Gem Load Error is: Could not find a
JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
This is being triggered by a couple of gems - ngannotate-rails and coffee-rails.
This is a rails 4.2 application with a angular.js frontend, being deployed to heroku for the first time.
Heroku stack:
$ heroku stack
=== my_app Available Stacks
heroku-16
* cedar-14
Buildpacks:
$ heroku buildpacks
=== my_app Buildpack URLs
1. https://github.com/prakashmurthy/heroku-buildpack-nodejs
2. heroku/ruby
Both the node.js build and ruby build complete successfully.
PATH seems to be set correctly:
$ heroku run bash
Running bash on ⬢ my_app... up, run.1502 (Free)
~ $ echo $PATH
/app/bin:/app/vendor/bundle/bin:/app/vendor/bundle/ruby/2.3.0/bin:/usr/local/bin:/usr/bin:/bin
Appreciate any help in figuring out this issue.