I am wanting to know how to go about deploying my docpad project to modulus.
Assuming I need to be running in production mode to do so. I noticed for the static deployment on docpad you just upload the contents of the out directory. If we are using a node server do we upload the entire project direcory. Which I did try but I don't think my docpad.coffee settings were correct. You can see below my attempt at this.
docpad.coffee
# ----------------
# Server Configuration
# Server Express
# ----------------
# The express.js instance that we want DocPad to use
# If not set, we will create our own
serverExpress: default
# ----------------
# Port
# ----------------
# Use to change the port that DocPad listens to
# By default we will detect the appropriate port number for our environment
# if no environment port number is detected we will use 9778 as the port number
# Checked environment variables are:
# - PORT - Heroku, Nodejitsu, Custom
# - VCAP_APP_PORT - AppFog
# - VMC_APP_PORT - CloudFoundry
port: - PORT
The First step according to the modulus site is to Use the environment variable PORT. app.listen(process.env.PORT) I assumed that would meant adding the - PORT to the docpad.coffee file.
As well I am not even sure how to have the site run in production when uploaded, remember I am just uploading the entire directory. Do I run a command from the Modulus server in terminal once the project is deployed?
Modulus also asks for the following in my packages.json file. I had most of them already except for the "main": "path/to/custom_main.js" which I assumed was the docpad.coffee file, so I linked to that.
Package.json
{
"name": "zurb-foundation.docpad",
"version": "0.4.0",
"description": "Zurb Foundation skeleton for DocPad. Simple and flexible HTML, CSS, and Javascript for popular user interface components and interactions.",
"homepage": "https://github.com/axyz/zurb-foundation.docpad",
"keywords": [
"docpad-skeleton",
"docpad",
"website",
"foundation",
"zurb foundation"
],
"author": "Andrea Moretti <axyzxp#gmail.com>",
"maintainers": [
"Andrea Moretti <axyzxp#gmail.com>"
],
"contributors": [
"Andrea Moretti <axyzxp#gmail.com>"
],
"bugs": {
"url": "https://github.com/axyz/zurb-foundation.docpad/issues"
},
"repository": {
"type": "git",
"url": "http://github.com/axyz/zurb-foundation.docpad.git"
},
"engines": {
"node": "0.10",
"npm": "1.3"
},
"main": "docpad.coffee",
"dependencies": {
"docpad": "~6.54.1",
"docpad-plugin-eco": "~2.0.2",
"docpad-plugin-livereload": "~2.5.3",
"docpad-plugin-coffeescript": "~2.2.2",
"express" : "2.5.x",
"ejs" : "0.8.x",
"docpad-plugin-nodesass": "~2.1.1"
},
"main": "node_modules/docpad/bin/docpad-server",
"scripts": {
"start": "node_modules/docpad/bin/docpad-server"
},
"devDependencies": {}
}
When I Deployed the site it did not work at all, I mean I had a link but the site didnt work. Any suggestions on what to do when deploying a docpad site to Modulus? I used the skeleton Foundation with Sass as well after installing docpad, which did work locally.
Ok still trying to get this thing working, when I run the site now it works locally, and when I deploy it I get a link to a modulus subdomian that doesnt work. I went and checked the logs on the modulus site and this is what I get
Modulus Logs
...
docpad-plugin-coffeescript#2.2.2 node_modules/docpad-plugin-coffeescript
└── coffee-script#1.6.3
docpad-plugin-eco#2.0.2 node_modules/docpad-plugin-eco
└── eco#1.1.0-rc-3 (strscan#1.0.1, coffee-script#1.6.3)
express#2.5.11 node_modules/express
├── qs#0.4.2
├── mime#1.2.4
├── mkdirp#0.3.0
└── connect#1.9.2 (formidable#1.0.14)
docpad-plugin-livereload#2.5.3 node_modules/docpad-plugin-livereload
├── extendr#2.1.0 (typechecker#2.0.8)
├── primus#1.4.4 (extendable#0.0.6, load#1.0.0)
└── ws#0.4.31 (tinycolor#0.0.1, options#0.0.5, commander#0.6.1, nan#0.3.2)
docpad#6.54.4 node_modules/docpad
├── lazy-require#1.0.0
├── eachr#2.0.2
├── extendr#2.1.0
├── extract-opts#2.2.0
├── caterpillar-filter#2.0.3
├── envfile#1.0.0
├── getmac#1.0.6
├── commander#2.0.0
├── ambi#2.1.6
├── typechecker#2.0.8
├── taskgroup#3.3.0
├── mime#1.2.11
├── query-engine#1.5.3
├── bal-util#2.3.2
├── safefs#3.0.3 (taskgroup#3.2.4)
├── semver#2.2.1
├── safeps#2.2.8 (taskgroup#3.2.4)
├── caterpillar-human#2.1.1 (ansistyles#0.1.1, ansicolors#0.2.1)
├── progressbar#1.0.3 (progress#1.1.2)
├── event-emitter-grouped#2.3.1 (taskgroup#3.2.4)
├── watchr#2.4.4 (taskgroup#3.2.4)
├── promptly#0.2.0 (read#1.0.5)
├── backbone#1.1.0 (underscore#1.5.2)
├── jschardet#1.1.0
├── superagent#0.15.7 (methods#0.0.1, cookiejar#1.3.0, debug#0.7.3, qs#0.6.5, emitter-component#1.0.0, reduce-component#1.0.1, mime#1.2.5, formidable#1.0.14)
├── lodash#2.2.1
├── cson#1.4.5 (requirefresh#1.1.2, coffee-script#1.6.3, js2coffee#0.2.3)
├── caterpillar#2.0.6 (readable-stream#1.1.9)
├── encoding#0.1.7 (iconv-lite#0.2.11)
├── yamljs#0.1.4 (glob#3.1.21, argparse#0.1.15)
└── express#3.4.4 (methods#0.1.0, range-parser#0.0.4, cookie-signature#1.0.1, fresh#0.2.0, debug#0.7.3, buffer-crc32#0.2.1, cookie#0.1.0, send#0.1.4, mkdirp#0.3.5, commander#1.3.2, connect#2.11.0)
docpad-plugin-nodesass#2.1.1 node_modules/docpad-plugin-nodesass
├── node-neat#1.0.0
├── node-bourbon#1.0.0
├── taskgroup#3.2.4 (ambi#2.1.6)
└── node-sass#0.7.0 (node-watch#0.3.4, colors#0.6.0-1, mkdirp#0.3.5, optimist#0.6.0, mocha#1.13.0)
INFO: Main file specified in package.json: node_modules/docpad/bin/docpad-server
INFO: Starting application.
[32minfo:[39m Welcome to DocPad v6.54.4 (global installation: /mnt/data/2/node_modules/docpad)
[32minfo:[39m Contribute: http://docpad.org/docs/contribute
[32minfo:[39m Plugins:
[32minfo:[39m Environment: production
[32minfo:[39m DocPad listening to http://localhost:8080/ on directory /mnt/data/2/node_modules/docpad/bin/out
[32minfo:[39m Generating...
[33mnotice:[39m DocPad is currently running without any plugins installed. You probably want to install some: http://docpad.org/plugins
Error: Cannot generate website as the src dir was not found
at /mnt/data/2/node_modules/docpad/out/lib/docpad.js:3102:21
at /mnt/data/2/node_modules/docpad/node_modules/safefs/out/lib/safefs.js:185:16
at Object.cb [as oncomplete] (fs.js:168:19)
[2013-11-03T17:19:32.095Z] Application initialized with pid 69363
The entire log file can be seen here https://gist.github.com/kitsondevelopment/7292623
It says it cant find the src directory however the source directory is there according to this screen shot so I do not understand.
Update
I just noticed that the error it is referring to the src directory in the node_modules/docpad directory, my app created with docpad run did not have a src directory in node_modules/docpad. WHy might this be?
Update:
It appears that modulus does something odd when just using package.json to set docpad as the entry point. My guess is that it doesn't set the current directory correctly.
I got it working by creating an app.js that just hands off execution to docpad (similar to the deployment instructions for AppFog:
module.exports = require(__dirname+'/node_modules/docpad/out/bin/docpad-server');
Then in package.json, I pointed main at app.js
"engines" : {
"node": "0.10",
"npm": "1.2"
},
"dependencies": {
... the dependencies from the skeleton ...
},
"main": "app.js",
===
You shouldn't set serverExpress at all. Remove that set of lines. You also shouldn't set port. The port setting in docpad.coffee is only if you want to hard code a specific port (which you don't). docpad will automatically look at all of the environment variables typically used by node hosts (including the one that Modulus is setting) and will figure out the correct port without you doing anything special.
Related
I would like to display the image mouse.jpg on the webiste. The website is displayed but the image is not.
I deployed using this guide on DigitalOcean. It uses apache, wsgi and virtualenv.
I found this on stackoverflow but could not transfer the answer to my problem. It is about writing files and not displaying.
I also found this and that but they do not include a web server like apache or nginx.
On AWS I setup the security group and allowed access on port 80 and 8080.
This is my tree in my home directory on the ec2:
nextstep
├── index.html
├── nextstep.py
├── nextstep.wsgi
├── static
│ └── mouse.jpg
└── templates
├── nextstep.html
nextstep.py looks like
from flask import Flask, render_template
import os
PEOPLE_FOLDER = os.path.join('static')
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = PEOPLE_FOLDER
#app.route('/')
def hello_world():
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'mouse.jpg')
return render_template('nextstep.html',user_image = full_filename)
if __name__ == '__main__':
app.run()
nextstep.wsgi looks like:
import sys
sys.path.insert(0, '/var/www/html/nextstep')
from nextstep import app as application
/etc/apache2/sites-available$ cat 000-default.conf looks like:
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp threads=5
WSGIScriptAlias /test /var/www/html/flaskapp/flaskapp.wsgi
<Directory flaskapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess nextstep threads=5
WSGIScriptAlias /nextstep /var/www/html/nextstep/nextstep.wsgi
<Directory nextstep>
WSGIProcessGroup nextstep
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
On EC2 tree of /var/www/html is:
.
├── flaskapp -> /home/ubuntu/flaskapp
├── index.html
└── nextstep -> /home/ubuntu/nextstep
nextstep.html looks like:
<html>
<body>
Hello World from nextstep.html
{{ user_image }}
next step 2
<img src="{{ user_image }}" alt="User Image">
<img src="/var/www/html/nextstep/static/mouse.jpg">
<img src="~/nextstep/static/mouse.jpg">
<img src="/home/nextstep/static/mouse.jpg">
<img src="home/nextstep/static/mouse.jpg">
<img src="static/mouse.jpg">
<img src="/static/mouse.jpg">
<img src="mouse.jpg">
<img src="/mouse.jpg">
</body>
</html>
I found the solution here: Setting up static folder path in Flask
In nextstep.py it is:
app = Flask(__name__, static_url_path="", static_folder="static")
In nextstep.html it is:
<img src="mouse.jpg">
I've successfully deployed my SmartContracts locally to Ganache and want to now take it to the next level by testing them on ROPSTEN.
For some reason, even though I've done this a million times before with other projects, when I run
truffle migrate --network ropsten
I'm not getting any sort of results, which is to say I'm not getting errors, but its also just not succeeding. It just says:
Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
...and puts me back at the prompt line, waiting for my next command.
My DEV ENVIRONMENT is:
Operating System: Mac OS Catalina v.10.15.1
Truffle Version (truffle version): v.5.0.34
Node Version (node --version): v.10.16.3
NPM Version (npm --version): v.6.14.4
├─┬ #truffle/hdwallet-provider#1.0.35
│ └── web3#1.2.1
├─┬ truffle-hdwallet-provider#1.0.17
│ └── web3#1.2.1
└── web3#0.20.7
(Yes, I seem to have two versions of Web3 - but I don't think that's the problem...)
My truffle-config.js file looks like this:
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider');
module.exports = {
ropsten: {
provider: function () {
return new HDWalletProvider(
process.env.GANACHE_MNENOMIC,
"https://ropsten.infura.io/${process.env.INFURA_API_KEY}"
)
},
network_id: 3,
from: "0xB4xxxxxxxxxxxxxxxxxxxxxxx",
gas: 8000000,
gasPrice: 20000000000,
confirmations: 2, // # of confs to wait between deployments. (default: 0)
skipDryRun: true
},
My .env file has the MNEMONICs and the INFURA_API_KEY which are all valid.
Any ideas what might be going on here?
You need a faucet and get some funds on your ropsten address so that migration of contract is executed.
I tried to use json config to run forever, but some config seems not work. I wonder whether my code is wrong, or it only supports --xxx commands like --minUptime, except -xxx commands like -m.
.
├── forever
│ └── proConfig.json
└── test_debug.js
// config.json
{
"append": true,
"watch": true,
"script": "test_debug.js",
"minUptime": "100ms",
"spinSleepTime": "10000ms",
// -------------------------
"MAX": 10,
"LOGFILE": "forever.log",
"OUTFILE": "out.log",
"ERRFILE": "err.log"
}
Command:
forever start forever/proConfig.json
Firstly, you should check the command line usage. It should be below command:
forever start forever/proConfig.json
Secondly, forever does not support minUptime, spinSleepTime, .... in the configuration file. Please try to add it to the command:
forever start --minUptime 1000 --spinSleepTime 1000 forever/proConfig.json
Trying to make my second Django app: a shop based on Django Oscar. I'm following the tutorial on RTFD. I have an issue with this stage http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html#creating-product-classes-and-fulfillment-partners.
Every Oscar deployment needs at least one product class and one
fulfillment partner. These aren’t created automatically as they’re
highly specific to the shop you want to build. The quickest way to set
them up is to log into the Django admin interface at
localhost:8000/admin/ and create instances of both there. For a
deployment setup, we recommend creating them as data migration.
However when I try to log into the admin the error generated is:
ProgrammingError at /admin/
(1146, "Table 'winestoreoscar.django_admin_log' doesn't exist")
....
Error during template rendering
In template /home/david/.virtualenvs/winestoreoscar/local/lib/python2.7/site-packages/django/contrib/admin/templates/admin/index.html, error at line 65
1146
This template is shown in the error with this line highlighted:
<ul class="actionlist">
**65 {% for entry in admin_log %}**
66 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
So it looks like I'm missing a table. I'm using MySQL as the database. In the mysql prompt I tried the obvious..
mysql> CREATE TABLE winestoreoscar.django_admin_log;
but got the error message...
ERROR 1113 (42000): A table must have at least 1 column
I then tried removing the whole for loop in the admin template, and admin rendered successfully, but attempting to save resulted in the previous error.
Now I'm stuck. Any help very much appreciated.
Edit:
Here's the tree from the base dir (Thinks - do I need an admin.py..?):
├── manage.py
└── oscarwinestore
├── __init__.py
├── __init__.pyc
├── settings.py
├── settings.py~
├── settings.pyc
├── urls.py
├── urls.py~
├── urls.pyc
├── wsgi.py
└── wsgi.pyc
my urls.py is
from django.conf.urls import include, url
from oscar.app import application
from django.contrib import admin
admin.autodiscover()
urlpatterns = [
url(r'^i18n/', include('django.conf.urls.i18n')),
# The Django admin is not officially supported; expect breakage.
# Nonetheless, it's often useful for debugging.
url(r'^admin/', include(admin.site.urls)),
url(r'', include(application.urls)),
]
You need to create the tables with syncdb and migrate, as per the docs:
$ python manage.py syncdb --noinput
$ python manage.py migrate
Have you done that?
I am trying to create simple rack app with static pages.
The structure of my app:
public
|-index.html
|-css
|-skins
|-blue
|-blue.css
|-yellow
|-yellow.css
....many more...
|-js
|-bootstrap
|-aide
|-abide.js
...many more...
config.ru
Gemfile
My config.ru file
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
The problem is that inside each folder "js", "css" I have hundreds of subdirectories and files and don't what to specify them manually. Can I load all subfoldres at once?
EDIT
With above configuration, when I ran rackup and pointed browser to localhost:9292. I ve just seen white screen loading. I thought that problem could be that subdirectories aren't loaded. But after I ve looked into log I found that my assets are being loaded in infinite loop and that's why app doesn't respond.
like
127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/gmap3.min.js?_=1390559355618 HTTP/1.1" 200 29735 0.0015
127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/waypoints.min.js?_=1390559355619 HTTP/1.1" 200 8044 0.0012
127.0.0.1 - - [24/Jan/2014 14:35:01] "GET /js/bootstrap/tab.js?_=1390559355620 HTTP/1.1" 200 3420 0.0009
All assets are loaded with 200 success status. I don't have any additional specific configurations. Gemfile is
source 'https://rubygems.org'
gem 'mail'
gem 'rack'
A correct index.html source could be a solution.
To debug what is happening, you can try to load your index.html with only one specific JS/Css file and temporary comment in all others to make sure you don't repeats you self.
Hope it helps.