From 5c8f016dd6f897262ea24e9c3424994d5d001084 Mon Sep 17 00:00:00 2001 From: fabianofranz Date: Fri, 12 Sep 2014 03:05:51 -0300 Subject: [PATCH] Fixes OpenShift --- .openshift/action_hooks/build | 11 +++ .openshift/action_hooks/deploy | 9 +++ .openshift/action_hooks/start | 3 + .openshift/action_hooks/stop | 8 +++ .openshift/config.mysql.yml | 107 ++++++++++++++++++++++++++++ .openshift/cron/daily/.gitignore | 0 .openshift/cron/hourly/.gitignore | 0 .openshift/cron/minutely/.gitignore | 0 .openshift/cron/monthly/.gitignore | 0 .openshift/cron/weekly/README | 16 +++++ .openshift/cron/weekly/chrono.dat | 1 + .openshift/cron/weekly/chronograph | 3 + .openshift/cron/weekly/jobs.allow | 12 ++++ .openshift/cron/weekly/jobs.deny | 7 ++ .openshift/settings.xml | 3 + README.md | 11 +++ 16 files changed, 191 insertions(+) create mode 100755 .openshift/action_hooks/build create mode 100755 .openshift/action_hooks/deploy create mode 100755 .openshift/action_hooks/start create mode 100755 .openshift/action_hooks/stop create mode 100644 .openshift/config.mysql.yml create mode 100644 .openshift/cron/daily/.gitignore create mode 100644 .openshift/cron/hourly/.gitignore create mode 100644 .openshift/cron/minutely/.gitignore create mode 100644 .openshift/cron/monthly/.gitignore create mode 100644 .openshift/cron/weekly/README create mode 100644 .openshift/cron/weekly/chrono.dat create mode 100755 .openshift/cron/weekly/chronograph create mode 100644 .openshift/cron/weekly/jobs.allow create mode 100644 .openshift/cron/weekly/jobs.deny create mode 100644 .openshift/settings.xml diff --git a/.openshift/action_hooks/build b/.openshift/action_hooks/build new file mode 100755 index 00000000..01fb76b8 --- /dev/null +++ b/.openshift/action_hooks/build @@ -0,0 +1,11 @@ +#!/bin/bash +cd $OPENSHIFT_REPO_DIR + +export NPM_CONFIG_CACHE="$OPENSHIFT_TMP_DIR/npm/cache" +export MAVEN_OPTS="-Dmaven.repo.local=$OPENSHIFT_TMP_DIR/m2" +export HOME="$OPENSHIFT_TMP_DIR/local" + +npm install npm +export PATH="$OPENSHIFT_REPO_DIR/node_modules/.bin:$PATH" + +mvn clean package diff --git a/.openshift/action_hooks/deploy b/.openshift/action_hooks/deploy new file mode 100755 index 00000000..9d146ad3 --- /dev/null +++ b/.openshift/action_hooks/deploy @@ -0,0 +1,9 @@ +#!/bin/bash +cd $OPENSHIFT_REPO_DIR +sed -i 's/@OPENSHIFT_DIY_IP@/'"$OPENSHIFT_DIY_IP"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_DIY_PORT@/'"$OPENSHIFT_DIY_PORT"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_APP_DNS@/'"$OPENSHIFT_APP_DNS"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_APP_NAME@/'"$OPENSHIFT_APP_NAME"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_MYSQL_DB_HOST@/'"$OPENSHIFT_MYSQL_DB_HOST"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_MYSQL_DB_USERNAME@/'"$OPENSHIFT_MYSQL_DB_USERNAME"'/g' .openshift/config.mysql.yml +sed -i 's/@OPENSHIFT_MYSQL_DB_PASSWORD@/'"$OPENSHIFT_MYSQL_DB_PASSWORD"'/g' .openshift/config.mysql.yml diff --git a/.openshift/action_hooks/start b/.openshift/action_hooks/start new file mode 100755 index 00000000..53ce9a5c --- /dev/null +++ b/.openshift/action_hooks/start @@ -0,0 +1,3 @@ +#!/bin/bash +cd $OPENSHIFT_REPO_DIR +nohup java -jar target/commafeed.jar server .openshift/config.mysql.yml > ${OPENSHIFT_DIY_LOG_DIR}/commafeed.log 2>&1 & diff --git a/.openshift/action_hooks/stop b/.openshift/action_hooks/stop new file mode 100755 index 00000000..c6bb29af --- /dev/null +++ b/.openshift/action_hooks/stop @@ -0,0 +1,8 @@ +#!/bin/bash +source $OPENSHIFT_CARTRIDGE_SDK_BASH +if [ -z "$(ps -ef | grep commafeed | grep -v grep)" ] +then + client_result "Application is already stopped" +else + kill `ps -ef | grep commafeed | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1 +fi diff --git a/.openshift/config.mysql.yml b/.openshift/config.mysql.yml new file mode 100644 index 00000000..3cefeb46 --- /dev/null +++ b/.openshift/config.mysql.yml @@ -0,0 +1,107 @@ +# CommaFeed settings +# ------------------ +app: + # context path of the application + contextPath: / + + # url used to access commafeed + publicUrl: https://@OPENSHIFT_APP_DNS@/ + + # wether to allow user registrations + allowRegistrations: false + + # put your google analytics tracking code here + googleAnalyticsTrackingCode: + + # number of http threads + backgroundThreads: 3 + + # number of database updating threads + databaseUpdateThreads: 1 + + # settings for sending emails (password recovery) + smtpHost: + smtpPort: + smtpTls: false + smtpUserName: + smtpPassword: + + # wether this commafeed instance has a lot of feeds to refresh + # leave this to false in almost all cases + heavyLoad: false + + # minimum amount of time commafeed will wait before refreshing the same feed + refreshIntervalMinutes: 15 + + # wether to enable pubsub + # probably not needed if refreshIntervalMinutes is low + pubsubhubbub: false + + # if enabled, images in feed entries will be proxied through the server instead of accessed directly by the browser + # useful if commafeed is usually accessed through a restricting proxy + imageProxyEnabled: false + + # database query timeout (in milliseconds), 0 to disable + queryTimeout: 0 + + # time to keep unread statuses (in days), 0 to disable + keepStatusDays: 0 + + # cache service to use, possible values are 'noop' and 'redis' + cache: noop + + # announcement string displayed on the main page + announcement: + +# Database connection +# ------------------- +# for MySQL +# driverClass is com.mysql.jdbc.Driver +# url is jdbc:mysql://localhost/commafeed?autoReconnect=true&failOverReadOnly=false&maxReconnects=20&rewriteBatchedStatements=true +# +# for PostgreSQL +# driverClass is org.postgresql.Driver +# url is jdbc:postgresql://localhost:5432/commafeed +# +# for Microsoft SQL Server +# driverClass is net.sourceforge.jtds.jdbc.Driver +# url is jdbc:jtds:sqlserver://localhost:1433/commafeed;instance= + +database: + driverClass: com.mysql.jdbc.Driver + url: jdbc:mysql://@OPENSHIFT_MYSQL_DB_HOST@/@OPENSHIFT_APP_NAME@?autoReconnect=true&failOverReadOnly=false&maxReconnects=20&rewriteBatchedStatements=true + user: @OPENSHIFT_MYSQL_DB_USERNAME@ + password: @OPENSHIFT_MYSQL_DB_PASSWORD@ + properties: + charSet: UTF-8 + maxWaitForConnection: 1s + validationQuery: "/* CommaFeed Health Check */ SELECT 1" + minSize: 1 + maxSize: 50 + checkConnectionWhileIdle: true + maxConnectionAge: 30m + +server: + applicationConnectors: + - type: http + port: @OPENSHIFT_DIY_PORT@ + bindHost: @OPENSHIFT_DIY_IP@ + adminConnectors: + - type: http + port: 15000 + bindHost: @OPENSHIFT_DIY_IP@ +logging: + level: WARN + loggers: + com.commafeed: INFO + liquibase: INFO + io.dropwizard.server.ServerFactory: INFO + appenders: + - type: console + - type: file + currentLogFilename: log/commafeed.log + threshold: ALL + archive: true + archivedLogFilenamePattern: log/commafeed-%d.log + archivedFileCount: 5 + timeZone: UTC diff --git a/.openshift/cron/daily/.gitignore b/.openshift/cron/daily/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/.openshift/cron/hourly/.gitignore b/.openshift/cron/hourly/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/.openshift/cron/minutely/.gitignore b/.openshift/cron/minutely/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/.openshift/cron/monthly/.gitignore b/.openshift/cron/monthly/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/.openshift/cron/weekly/README b/.openshift/cron/weekly/README new file mode 100644 index 00000000..7c3e659f --- /dev/null +++ b/.openshift/cron/weekly/README @@ -0,0 +1,16 @@ +Run scripts or jobs on a weekly basis +===================================== +Any scripts or jobs added to this directory will be run on a scheduled basis +(weekly) using run-parts. + +run-parts ignores any files that are hidden or dotfiles (.*) or backup +files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles +the files named jobs.deny and jobs.allow specially. + +In this specific example, the chronograph script is the only script or job file +executed on a weekly basis (due to white-listing it in jobs.allow). And the +README and chrono.dat file are ignored either as a result of being black-listed +in jobs.deny or because they are NOT white-listed in the jobs.allow file. + +For more details, please see ../README.cron file. + diff --git a/.openshift/cron/weekly/chrono.dat b/.openshift/cron/weekly/chrono.dat new file mode 100644 index 00000000..fc4abb87 --- /dev/null +++ b/.openshift/cron/weekly/chrono.dat @@ -0,0 +1 @@ +Time And Relative D...n In Execution (Open)Shift! diff --git a/.openshift/cron/weekly/chronograph b/.openshift/cron/weekly/chronograph new file mode 100755 index 00000000..61de949f --- /dev/null +++ b/.openshift/cron/weekly/chronograph @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "`date`: `cat $(dirname \"$0\")/chrono.dat`" diff --git a/.openshift/cron/weekly/jobs.allow b/.openshift/cron/weekly/jobs.allow new file mode 100644 index 00000000..8d32abc7 --- /dev/null +++ b/.openshift/cron/weekly/jobs.allow @@ -0,0 +1,12 @@ +# +# Script or job files listed in here (one entry per line) will be +# executed on a weekly-basis. +# +# Example: The chronograph script will be executed weekly but the README +# and chrono.dat files in this directory will be ignored. +# +# The README file is actually ignored due to the entry in the +# jobs.deny which is checked before jobs.allow (this file). +# +chronograph + diff --git a/.openshift/cron/weekly/jobs.deny b/.openshift/cron/weekly/jobs.deny new file mode 100644 index 00000000..73c94500 --- /dev/null +++ b/.openshift/cron/weekly/jobs.deny @@ -0,0 +1,7 @@ +# +# Any script or job files listed in here (one entry per line) will NOT be +# executed (read as ignored by run-parts). +# + +README + diff --git a/.openshift/settings.xml b/.openshift/settings.xml new file mode 100644 index 00000000..8cfcb0a7 --- /dev/null +++ b/.openshift/settings.xml @@ -0,0 +1,3 @@ + + $OPENSHIFT_DATA_DIR + diff --git a/README.md b/README.md index 575127c8..469e032f 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ Issue the following command to run the app, the server will listen by default on java -jar target/commafeed.jar server config.yml You can use a proxy http server such as nginx or apache. + +Deployment on OpenShift +----------------------------- + + [OpenShift](https://openshift.redhat.com) is Red Hat's Platform-as-a-Service (PaaS) that allows developers to quickly develop, host, and scale applications in a cloud environment. Commafeed runs perfectly on OpenShift and can even be used in the free tier. Follow the [Getting Started](https://developers.openshift.com/en/getting-started-overview.html) guide and after you sign up and install the Command Line Tools (RHC), do: + + rhc create-app commafeed diy-0.1 mysql-5.5 + cd commafeed + git remote add upstream -m master https://github.com/Athou/commafeed.git + git pull -s recursive -X theirs upstream master + git push Local development -----------------