mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding wsgi server to use new virtualenv gunicorn.
This commit is contained in:
parent
94d981cfac
commit
3406958e8a
20 changed files with 156 additions and 110 deletions
|
@ -1,5 +1,5 @@
|
|||
[program:celerybeat]
|
||||
command=/srv/newsblur/manage.py celerybeat --schedule=/srv/newsblur/data/celerybeat-schedule.db --loglevel=INFO
|
||||
command=/srv/newsblur/manage.py celery beat --schedule=/srv/newsblur/data/celerybeat-schedule.db --loglevel=INFO
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[program:celery]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q new_feeds,push_feeds,update_feeds
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q new_feeds,push_feeds,update_feeds
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
directory=/srv/newsblur
|
||||
user=sclay
|
||||
numprocs=1
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celeryd_beat]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q beat_tasks -c 3
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q beat_tasks -c 3
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd_beat.log
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celeryd_beat_feeds]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q beat_feeds_task -c 1
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q beat_feeds_task -c 1
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd_beat_feeds.log
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celery]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q new_feeds,push_feeds
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q new_feeds,push_feeds
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd.log
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celeryd_search_indexer]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q search_indexer -c 16
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q search_indexer -c 16
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd_searchindexer.log
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celeryd_search_indexer_tasker]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q search_indexer_tasker -c 2
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q search_indexer_tasker -c 2
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd_searchindexer_tasker.log
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:celeryd_work_queue]
|
||||
command=/srv/newsblur/manage.py celeryd --loglevel=INFO -Q work_queue
|
||||
command=/srv/newsblur/manage.py celery worker --loglevel=INFO -Q work_queue
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
numprocs=1
|
||||
stdout_logfile=/var/log/celeryd_workqueue.log
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[program:gunicorn]
|
||||
#command=/home/conesus/newsblur/manage.py run_gunicorn -c gunicorn_conf.py
|
||||
command=gunicorn_django -c config/gunicorn_conf.py
|
||||
command=gunicorn -c config/gunicorn_conf.py wsgi
|
||||
directory=/srv/newsblur
|
||||
environment=PATH="/srv/newsblur/venv/bin"
|
||||
user=sclay
|
||||
autostart=true
|
||||
autorestart=true
|
||||
|
|
|
@ -8,3 +8,4 @@ autorestart=true
|
|||
priority=991
|
||||
stopsignal=HUP
|
||||
stdout_logfile = /srv/newsblur/logs/favicons.log
|
||||
environment = NODE_ENV=production
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:node_original_page]
|
||||
command=node original_page.js
|
||||
directory=/srv/newsblur/node
|
||||
environment=NODE_ENV=production
|
||||
user=sclay
|
||||
autostart=true
|
||||
autorestart=true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[program:node_unread]
|
||||
command=node node/unread_counts.js
|
||||
directory=/srv/newsblur
|
||||
environment=NODE_ENV=production
|
||||
user=sclay
|
||||
autostart=true
|
||||
autorestart=true
|
||||
|
@ -8,4 +9,3 @@ autorestart=true
|
|||
priority=991
|
||||
stopsignal=HUP
|
||||
stdout_logfile = /srv/newsblur/logs/unread_counts.log
|
||||
environment = NODE_ENV=production
|
|
@ -5,6 +5,15 @@ DEV = process.env.NODE_ENV == 'development'
|
|||
MONGODB_SERVER = if DEV then 'localhost' else 'db_mongo'
|
||||
MONGODB_PORT = parseInt(process.env.MONGODB_PORT or 27017, 10)
|
||||
|
||||
console.log " ---> Starting NewsBlur Favicon server..."
|
||||
if !DEV and !process.env.NODE_ENV
|
||||
console.log " ---> Specify NODE_ENV=<development,production>"
|
||||
return
|
||||
else if DEV
|
||||
console.log " ---> Running as development server"
|
||||
else
|
||||
console.log " ---> Running as production server"
|
||||
|
||||
if DEV
|
||||
server = new mongo.Server(MONGODB_SERVER, MONGODB_PORT,
|
||||
auto_reconnect: true
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
(function() {
|
||||
var DEV, MONGODB_PORT, MONGODB_SERVER, app, db, express, mongo, server,
|
||||
_this = this;
|
||||
var DEV, MONGODB_PORT, MONGODB_SERVER, app, db, express, mongo, server;
|
||||
|
||||
express = require('express');
|
||||
|
||||
|
@ -13,6 +12,17 @@
|
|||
|
||||
MONGODB_PORT = parseInt(process.env.MONGODB_PORT || 27017, 10);
|
||||
|
||||
console.log(" ---> Starting NewsBlur Favicon server...");
|
||||
|
||||
if (!DEV && !process.env.NODE_ENV) {
|
||||
console.log(" ---> Specify NODE_ENV=<development,production>");
|
||||
return;
|
||||
} else if (DEV) {
|
||||
console.log(" ---> Running as development server");
|
||||
} else {
|
||||
console.log(" ---> Running as production server");
|
||||
}
|
||||
|
||||
if (DEV) {
|
||||
server = new mongo.Server(MONGODB_SERVER, MONGODB_PORT, {
|
||||
auto_reconnect: true,
|
||||
|
@ -37,36 +47,40 @@
|
|||
|
||||
app.use(express.bodyParser());
|
||||
|
||||
db.open(function(err, client) {
|
||||
return client.collection("feed_icons", function(err, collection) {
|
||||
_this.collection = collection;
|
||||
});
|
||||
});
|
||||
db.open((function(_this) {
|
||||
return function(err, client) {
|
||||
return client.collection("feed_icons", function(err, collection) {
|
||||
_this.collection = collection;
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
|
||||
app.get(/^\/rss_feeds\/icon\/(\d+)\/?/, function(req, res) {
|
||||
var etag, feed_id;
|
||||
feed_id = parseInt(req.params, 10);
|
||||
etag = req.header('If-None-Match');
|
||||
return _this.collection.findOne({
|
||||
_id: feed_id
|
||||
}, function(err, docs) {
|
||||
console.log("Req: " + feed_id + ", etag: " + etag + "/" + (docs != null ? docs.color : void 0) + " (err: " + err + ", docs? " + (!!(docs && docs.data)) + ")");
|
||||
if (!err && etag && docs && (docs != null ? docs.color : void 0) === etag) {
|
||||
return res.send(304);
|
||||
} else if (!err && docs && docs.data) {
|
||||
res.header('etag', docs.color);
|
||||
return res.send(new Buffer(docs.data, 'base64'), {
|
||||
"Content-Type": "image/png"
|
||||
});
|
||||
} else {
|
||||
if (DEV) {
|
||||
return res.redirect('/media/img/icons/circular/world.png');
|
||||
app.get(/^\/rss_feeds\/icon\/(\d+)\/?/, (function(_this) {
|
||||
return function(req, res) {
|
||||
var etag, feed_id;
|
||||
feed_id = parseInt(req.params, 10);
|
||||
etag = req.header('If-None-Match');
|
||||
return _this.collection.findOne({
|
||||
_id: feed_id
|
||||
}, function(err, docs) {
|
||||
console.log("Req: " + feed_id + ", etag: " + etag + "/" + (docs != null ? docs.color : void 0) + " (err: " + err + ", docs? " + (!!(docs && docs.data)) + ")");
|
||||
if (!err && etag && docs && (docs != null ? docs.color : void 0) === etag) {
|
||||
return res.send(304);
|
||||
} else if (!err && docs && docs.data) {
|
||||
res.header('etag', docs.color);
|
||||
return res.send(new Buffer(docs.data, 'base64'), {
|
||||
"Content-Type": "image/png"
|
||||
});
|
||||
} else {
|
||||
return res.redirect('https://www.newsblur.com/media/img/icons/circular/world.png');
|
||||
if (DEV) {
|
||||
return res.redirect('/media/img/icons/circular/world.png');
|
||||
} else {
|
||||
return res.redirect('https://www.newsblur.com/media/img/icons/circular/world.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
|
||||
app.listen(3030);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
(function() {
|
||||
var info;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
(function() {
|
||||
var DB_PATH, DEV, app, express, fs, mkdirp, path, splitFeedId,
|
||||
_this = this;
|
||||
var DB_PATH, DEV, app, express, fs, mkdirp, path, splitFeedId;
|
||||
|
||||
express = require('express');
|
||||
|
||||
|
@ -21,50 +20,54 @@
|
|||
|
||||
app.listen(3060);
|
||||
|
||||
app.get(/^\/original_page\/(\d+)\/?/, function(req, res) {
|
||||
var etag, feedId, feedIdDir, filePath, lastModified;
|
||||
feedId = parseInt(req.params, 10);
|
||||
etag = req.header('If-None-Match');
|
||||
lastModified = req.header('If-Modified-Since');
|
||||
feedIdDir = splitFeedId(feedId);
|
||||
filePath = "" + DB_PATH + "/" + feedIdDir + ".zhtml";
|
||||
return path.exists(filePath, function(exists, err) {
|
||||
console.log((" ---> Loading: " + feedId + " (" + filePath + "). ") + ("" + (exists ? "" : "NOT FOUND")));
|
||||
if (!exists) {
|
||||
return res.send(404);
|
||||
}
|
||||
return fs.stat(filePath, function(err, stats) {
|
||||
if (!err && etag && stats.mtime === etag) {
|
||||
return res.send(304);
|
||||
app.get(/^\/original_page\/(\d+)\/?/, (function(_this) {
|
||||
return function(req, res) {
|
||||
var etag, feedId, feedIdDir, filePath, lastModified;
|
||||
feedId = parseInt(req.params, 10);
|
||||
etag = req.header('If-None-Match');
|
||||
lastModified = req.header('If-Modified-Since');
|
||||
feedIdDir = splitFeedId(feedId);
|
||||
filePath = "" + DB_PATH + "/" + feedIdDir + ".zhtml";
|
||||
return path.exists(filePath, function(exists, err) {
|
||||
console.log((" ---> Loading: " + feedId + " (" + filePath + "). ") + ("" + (exists ? "" : "NOT FOUND")));
|
||||
if (!exists) {
|
||||
return res.send(404);
|
||||
}
|
||||
if (!err && lastModified && stats.mtime === lastModified) {
|
||||
return res.send(304);
|
||||
}
|
||||
return fs.readFile(filePath, function(err, content) {
|
||||
res.header('Etag', Date.parse(stats.mtime));
|
||||
return res.send(content);
|
||||
return fs.stat(filePath, function(err, stats) {
|
||||
if (!err && etag && stats.mtime === etag) {
|
||||
return res.send(304);
|
||||
}
|
||||
if (!err && lastModified && stats.mtime === lastModified) {
|
||||
return res.send(304);
|
||||
}
|
||||
return fs.readFile(filePath, function(err, content) {
|
||||
res.header('Etag', Date.parse(stats.mtime));
|
||||
return res.send(content);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
|
||||
app.post(/^\/original_page\/(\d+)\/?/, function(req, res) {
|
||||
var feedId, feedIdDir, filePath, filePathDir, html;
|
||||
feedId = parseInt(req.params, 10);
|
||||
feedIdDir = splitFeedId(feedId);
|
||||
html = req.param("original_page");
|
||||
filePath = "" + DB_PATH + "/" + feedIdDir + ".zhtml";
|
||||
filePathDir = path.dirname(filePath);
|
||||
return mkdirp(filePathDir, function(err) {
|
||||
return fs.rename(req.files.original_page.path, filePath, function(err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log(" ---> Saving: " + feedId + " (" + filePath + ")");
|
||||
return res.send("OK");
|
||||
app.post(/^\/original_page\/(\d+)\/?/, (function(_this) {
|
||||
return function(req, res) {
|
||||
var feedId, feedIdDir, filePath, filePathDir, html;
|
||||
feedId = parseInt(req.params, 10);
|
||||
feedIdDir = splitFeedId(feedId);
|
||||
html = req.param("original_page");
|
||||
filePath = "" + DB_PATH + "/" + feedIdDir + ".zhtml";
|
||||
filePathDir = path.dirname(filePath);
|
||||
return mkdirp(filePathDir, function(err) {
|
||||
return fs.rename(req.files.original_page.path, filePath, function(err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
console.log(" ---> Saving: " + feedId + " (" + filePath + ")");
|
||||
return res.send("OK");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
|
||||
splitFeedId = function(feedId) {
|
||||
var rgx;
|
||||
|
|
|
@ -16,10 +16,11 @@ if SECURE
|
|||
privateKey = fs.readFileSync('./config/certificates/newsblur.com.key').toString()
|
||||
certificate = fs.readFileSync('./config/certificates/newsblur.com.crt').toString()
|
||||
# ca = fs.readFileSync('./config/certificates/intermediate.crt').toString()
|
||||
io = require('socket.io').listen 8889
|
||||
options =
|
||||
key: privateKey
|
||||
cert: certificate
|
||||
# ca: ca
|
||||
io = require('socket.io').listen 8889, options
|
||||
|
||||
else
|
||||
io = require('socket.io').listen 8888
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.4.0
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
(function() {
|
||||
var REDIS_SERVER, SECURE, certificate, fs, io, log, privateKey, redis;
|
||||
var REDIS_SERVER, SECURE, certificate, fs, io, log, options, privateKey, redis;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
|
@ -15,10 +15,11 @@
|
|||
if (SECURE) {
|
||||
privateKey = fs.readFileSync('./config/certificates/newsblur.com.key').toString();
|
||||
certificate = fs.readFileSync('./config/certificates/newsblur.com.crt').toString();
|
||||
io = require('socket.io').listen(8889, {
|
||||
options = {
|
||||
key: privateKey,
|
||||
cert: certificate
|
||||
});
|
||||
};
|
||||
io = require('socket.io').listen(8889, options);
|
||||
} else {
|
||||
io = require('socket.io').listen(8888);
|
||||
}
|
||||
|
@ -38,8 +39,7 @@
|
|||
var ip;
|
||||
ip = socket.handshake.headers['X-Forwarded-For'] || socket.handshake.address.address;
|
||||
socket.on('subscribe:feeds', function(feeds, username) {
|
||||
var _ref,
|
||||
_this = this;
|
||||
var _ref;
|
||||
this.feeds = feeds;
|
||||
this.username = username;
|
||||
log.info(this.username, ("Connecting (" + feeds.length + " feeds, " + ip + "),") + (" (" + (io.sockets.clients().length) + " users on) ") + (" " + (SECURE ? "(SSL)" : "(non-SSL)")));
|
||||
|
@ -57,18 +57,22 @@
|
|||
console.log(" ---> Error: " + err);
|
||||
return socket.subscribe.end();
|
||||
});
|
||||
socket.subscribe.on("connect", function() {
|
||||
socket.subscribe.subscribe(_this.feeds);
|
||||
return socket.subscribe.subscribe(_this.username);
|
||||
});
|
||||
return socket.subscribe.on('message', function(channel, message) {
|
||||
log.info(_this.username, "Update on " + channel + ": " + message);
|
||||
if (channel === _this.username) {
|
||||
return socket.emit('user:update', channel, message);
|
||||
} else {
|
||||
return socket.emit('feed:update', channel, message);
|
||||
}
|
||||
});
|
||||
socket.subscribe.on("connect", (function(_this) {
|
||||
return function() {
|
||||
socket.subscribe.subscribe(_this.feeds);
|
||||
return socket.subscribe.subscribe(_this.username);
|
||||
};
|
||||
})(this));
|
||||
return socket.subscribe.on('message', (function(_this) {
|
||||
return function(channel, message) {
|
||||
log.info(_this.username, "Update on " + channel + ": " + message);
|
||||
if (channel === _this.username) {
|
||||
return socket.emit('user:update', channel, message);
|
||||
} else {
|
||||
return socket.emit('feed:update', channel, message);
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
});
|
||||
return socket.on('disconnect', function() {
|
||||
var _ref, _ref1;
|
||||
|
|
|
@ -525,7 +525,6 @@ REDIS_SESSIONS = {
|
|||
}
|
||||
|
||||
CELERY_REDIS_DB_NUM = 4
|
||||
CELERY_REDIS_DB = CELERY_REDIS_DB_NUM
|
||||
SESSION_REDIS_DB = 5
|
||||
|
||||
# =================
|
||||
|
@ -566,16 +565,11 @@ S3_AVATARS_BUCKET_NAME = 'avatars.newsblur.com'
|
|||
# ==================
|
||||
# = Configurations =
|
||||
# ==================
|
||||
try:
|
||||
from gunicorn_conf import *
|
||||
except ImportError, e:
|
||||
pass
|
||||
|
||||
from local_settings import *
|
||||
|
||||
if not DEBUG:
|
||||
INSTALLED_APPS += (
|
||||
'gunicorn',
|
||||
'raven.contrib.django',
|
||||
'django_ses',
|
||||
|
||||
|
|
12
wsgi.py
Normal file
12
wsgi.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
"""
|
||||
WSGI config for myproject project.
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
application = get_wsgi_application()
|
Loading…
Add table
Reference in a new issue