import configparser
import io
import location
+import logging
import ssl
import tempfile
import tornado.httpclient
DEFAULT_CONFIG = io.StringIO("""
[global]
debug = false
+environment = testing
data_dir =
static_dir = %(data_dir)s/static
templates_dir = %(data_dir)s/templates
""")
+# Setup logging
+log = logging.getLogger(__name__)
+
class Backend(object):
version = 0
return cp
+ @property
+ def environment(self):
+ """
+ Returns whether this is running in "production" or "testing"
+ """
+ return self.config.get("global", "environment")
+
def setup_database(self):
"""
Sets up the database connection.
if not func:
raise ValueError("Unknown task: %s" % task)
+ # Check if we are running in production
+ if not self.environment == "production":
+ log.warning("Refusing to run task '%s' in '%s' environment" % (task, self.environment))
+ return
+
# Run the task
r = await func(*args, **kwargs)
SHELL=/bin/bash
# Update blog feeds once an hour
-0 * * * * nobody ipfire.org update-blog-feeds
+0 * * * * nobody ipfire.org --logging=error update-blog-feeds
# Scan for release files once an hour
-0 * * * * nobody ipfire.org scan-files
+0 * * * * nobody ipfire.org --logging=error scan-files
# Send messages
-* * * * * nobody flock /tmp/.ipfire.org.send-all-messages.lock ipfire.org send-all-messages
+* * * * * nobody flock /tmp/.ipfire.org.send-all-messages.lock ipfire.org --logging=error send-all-messages
# Run campaigns
*/5 * * * * nobody ipfire.org --logging=error run-campaigns
# Announce blog posts
-*/5 * * * * nobody flock /tmp/.ipfire.org.announce-blog-posts ipfire.org announce-blog-posts
+*/5 * * * * nobody flock /tmp/.ipfire.org.announce-blog-posts ipfire.org --logging=error announce-blog-posts
# Cleanup once an hour
-30 * * * * nobody ipfire.org cleanup
+30 * * * * nobody ipfire.org --logging=error cleanup
# Check mirrors once every 30 min
*/30 * * * * nobody ipfire.org --logging=error check-mirrors
# Toot once a day
-0 8 * * * nobody sleep ${RANDOM} && ipfire.org toot
+0 8 * * * nobody sleep ${RANDOM} && ipfire.org --logging=error toot