Look at LSB init scripts for more information.
Copy to /etc/init.d:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)Look at LSB init scripts for more information.
Copy to /etc/init.d:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)| module AuthHelper | |
| def http_login | |
| user = 'username' | |
| pw = 'password' | |
| request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) | |
| end | |
| end | |
| module AuthRequestHelper | |
| # |
| class UrlValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| valid = begin | |
| URI.parse(value).kind_of?(URI::HTTP) | |
| rescue URI::InvalidURIError | |
| false | |
| end | |
| unless valid | |
| record.errors[attribute] << (options[:message] || "is an invalid URL") |
| description "nginx http daemon" | |
| start on runlevel [2] | |
| stop on runlevel [016] | |
| console owner | |
| exec /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf -g "daemon off;" | |
| respawn |
| Tested on: Rails 3.1, Mongoid 2.0.1, pg 0.12.0 gem | |
| Migrate from Mongo to PG | |
| 1. remove mongoid gem | |
| 2. add pg gem | |
| 3. in application.rb re-add ActiveRecord | |
| 4. for all models | |
| - inherit from ActiveRecord::Base | |
| - get rid of Mongoid:Document line | |
| - make migrations and put fields there |
| # run with: god -c /path/to/config.god [add -D if you want to not-deamonize god] | |
| # This is the actual config file used to keep the delayed_job running | |
| APPLICATION_ROOT = "/var/www/application" | |
| RAILS_ENV = "production" | |
| God.watch do |w| | |
| w.name = "delayed_job_production" | |
| w.interval = 15.seconds | |
| w.start = "/bin/bash -c 'cd #{APPLICATION_ROOT}/current; /usr/bin/env RAILS_ENV=#{RAILS_ENV} #{APPLICATION_ROOT}/current/script/delayed_job start > /tmp/delay_job.out'" |
| # MySQL. Versions 4.1 and 5.0 are recommended. | |
| # | |
| # Install the MySQL driver: | |
| # gem install mysql2 | |
| # | |
| # And be sure to use new-style password hashing: | |
| # http://dev.mysql.com/doc/refman/5.0/en/old-client.html | |
| development: | |
| adapter: mysql2 | |
| encoding: utf8 |