How do i deploy a blohg app to Dotcloud? - deployment

I made a dynamic website with blohg (http://blohg.org), a Mercurial/Flask/reST-based blogging engine, and it works on my machine.
I tried to deploy the website/app to Dotcloud following http://docs.blohg.org/deploy/ and http://docs.dotcloud.com/services/python/, ensuring that my dotcloud.yml and wsgi.py files were in the right place.
But when i viewed my app on my Dotcloud URL i got
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
My wsgi.py file is this:
from blohg import create_app
application = create_app('<my_app_name>')
I don't know what's wrong.
Is there some way i can turn on debug mode to find out? Have any of you successfully deployed at blohg app to Dotcloud? Any tips?
Thanks for your attention.

Do you have any utf-8 encoded content in your repository?
If yes, add this to the top of the wsgi file:
import os
os.environ['HGENCODING'] = 'utf-8'
this is a know bug in the wsgi script template, that will be fixed for
the next release.
If not, I'll need to take a deep look on dotcloud deployment process.

Related

Vs Code Issue: no code output. how do i fix this?

I am very new to coding and am trying to write a practice script for webscraping in VS Code Editor. But every time i run the script i get this issue of there being no real output. Can you please advise on what the issue is? Note: the pink boxes are just covering my nameenter image description here
I tried running the code and expected webscraped data from the link. I have tried many different scripts and the same issue happens. So there must be something wrong with the whole system i think
VSCode is an excellent IDE. When you start a new project (or open a folder in VSCode), it does not come with any build tools or compilers etc. You have to manually configure them. You have to set up the environment using different toolchains. Here are some instructions for Python
This is not a problem with VSCode but I am going to answer your question.
You can't webscrape indeed.com with requests and beatiful soup because it has bot protection using cloudflare. If you take a closer look to the response it returns the 403 Forbidden status code instead of 200 OK. You can scrape using a headless browser using selenium.
Here's an example
First install selenium and webdriver_manager
pip install selenium webdriver_manager
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# Make sure you are not detected as HeadlessChrome, some sites will refuse access
options = ChromeOptions()
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = Chrome(options=options, service=Service(
ChromeDriverManager().install()))
# Make sure you are not detected as HeadlessChrome, some sites will refuse access
ua = driver.execute_script("return navigator.userAgent").replace(
"HeadlessChrome", "Chrome")
driver.execute_cdp_cmd("Network.setUserAgentOverride", {
"userAgent": ua})
driver.execute_script(
"Object.defineProperty(navigator,'webdriver',{get:()=>undefined});")
driver.get("https://www.indeed.com/companies/best-Agriculture-companies")
main = driver.find_element(By.ID, "main")

how to to host single-spa root-config and modules on a central server during development

I've been experimenting with single-spa for a while, and understand the basics of the developer experience. Create a parcel, yarn start on a unique port, add the reference to the import map declaration, and so on. The challenge with this is that as my root-config accrues more and more modules managing ports and import-maps starts to get tedious. What I want is to publish these modules to a central repository and load them from there (e.g., http://someserver.com/repository/moduleA/myorg-modulea.js, etc.).
I was recently introduced to localstack and started thinking maybe a local S3 bucket would serve for this. I have a configuration where builds (yarn build) are automatically published to an s3 bucket running on localstack. But when I try to load the root config index.html from the bucket I get the following JS error:
Unable to resolve bare specifier '#myorg/root-config'
I can access the JS files for each parcel and the root-config just fine via curl, so I suppose this would be a problem with any http server used in the same way. I can flip the root config to use the standard webpack-dev-server instead (on port 9000) and it works okay. So I'm guessing there's a difference between how a production build resolves these modules vs. the local build.
Has anyone tried something like this and got it working?
I had a similar issue that I got to work with http-server by adding each child .js file to a sub-folder in the root-config directory and launching the web server at the root-config directory level.
"imports": {
"#myorg/root-config": "http://someserver.com/root-config.js",
"#myorg/moduleA": "http://someserver.com/modules/moduleA/myorg-modulea.js",
"#myorg/moduleB": "http://someserver.com/modules/moduleB/myorg-moduleb.js",
"#myorg/moduleC": "http://someserver.com/modules/moduleC/myorg-modulec.js",
}
Note: By default, Single-SPA has an "isLocal" check before the current import mappings. You'll need to remove this if using a production build or it won't load the correct mappings.
<% if (isLocal) { %>
In my case, I was using localhost instead of someserver so I could navigate into the 'repository' folder and run npx http-server to get everything to run correctly.
I was hung up on this for a little while so hopefully this leads you in the right direction.
For the record, after trying several approaches to hosting a repository as described above, I found the unresolved bare specifier problem went away. So I have to chalk that up as just not having the right URL in the import map. Measure twice, cut once.

My restaurant review project needs to work offline, but my local simple server shows 404 error

I am working on a project for Udacity. I am supposed to start a a simple HTTP server for my directory, but when I am trying to view the file on http://localhost:8000/ I see a different file and my terminal shows file not found error. I'm sure I must've done something, but I don't know how to fix this. Please HELP!

How do I deploy a Railo project to AWS using Eclipse?

I'm running a Railo project on my local Ubuntu box, Eclipse Indigo, Tomcat 7, Fusebox 4 and AWS Toolkit for Eclipse
I have my project running smoothly on my local dev box. Trying to deploy the project at times takes under 10min (very rare) and other times it never happens, just have the loading bar showing and/or eventually fails.
I've tried publishing a new project which works at times, but when trying to do incremental deployment it just almost never happens (it worked once). In fact after the one time when I deployed the project I've not been able to do it again.
Unable to upload application to Amazon S3: Unable to calculate MD5 hash: /home/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/aws-eclipse-1365821331354619151.war (No such file or directory)
Unable to calculate MD5 hash: /home/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/aws-eclipse-1365821331354619151.war (No such file or directory)
Rightly so, there is no such file in that location. But why? Is it a permissions issue? I gave myself root right for GUI file browser but still no joy (gksu nautilus).
I'm new to AWS and Ubuntu environment and not sure what i should do in order to deploy.
So one of your questions seems to be problems in uploading files to S3 via the AWS java SDK right?.. on line 1011 https://github.com/amazonwebservices/aws-sdk-for-java/blob/master/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java#L1011
So what I think your doing here is trying to execute a putObject S3 command which had a Content-MD5 hash saying the request could not be authenticated. I had this issue I found out that the MD5 hash needs to be base64 encoded and is required by Amazon to upload files.
However, looking at your error "No such file or directory" this could be a different issue. Doing a quick Google I found a post that could be of interest...
https://forums.aws.amazon.com/message.jspa?messageID=143497
Hope some of this helps.

Dotcloud uWSGI Error

I am trying to deploy one of my applications on dotcloud. However, I keep getting:
uWSGI Error
wsgi application not found
Somebody could hint at some useful docs where this issue is discussed? My application is here:
https://github.com/kfk/datacrowd
and I do think everything is done by the tutorials.
Not sure if you looked at this page or not, but it is a good resource for deploying flask apps onto dotCloud. http://flask.pocoo.org/snippets/48/
Looking at your application, it looks like most things are setup correctly the only thing that looks a little odd is your wsgi.py file.
Have you tried to change your wsgi.py file so that it looks like this.
import sys
sys.path.append('/home/dotcloud/current')
from datacrowd.app import app as application
application.config.update(DEBUG=True)
basically I removed the if statement at the end. Try that and see if it helps at all.
If not, try commenting out the application.config.update(DEBUG=True) line and see if that helps as well.
oh yeah one more thing, it looks like you have a static file instead of a static directory, not sure if you did that on purpose or not, but usually static is a directory where you put your static media, so that is most likely suppose to be symlink to datacrowd/static
Update:
Since you had the same error, then it is most likely something wrong with your application.
ssh into your service.
$ dotcloud ssh <app.service>
And then look at your logs in /var/log/supervisor/uwsgi.log, you will most likely see a syntax error, and a stack trace, telling you where the error is.
Common issues are usually
dependencies not being installed
Using features from a new version of python. (python 2.7, 3.x, features) when the python version on dotCloud is only 2.6.x.
syntax typos (indent issues, etc)