Commit b8fe0d96 by John Doe

added local environment with bootstrap rake task

parent dcc312e4
......@@ -28,13 +28,15 @@ class UpdateDb
entries = __create_entries(schema)
updater = UpdateFolder.new(@root_folder, entries)
# update db attributes from dbinfo
@db.size_total = dbinfo[:size_total]
@db.size_db = dbinfo[:size_db]
@db.size_other = dbinfo[:size_other]
@db.version = dbinfo[:version]
#@root_folder.transaction do
absorb_status(updater.run)
#end
@db.save
set_notice("Database refreshed")
self
......
......@@ -51,7 +51,7 @@ class UpdateStream
# specified DbStream
def __build_decimations(stream:, entry_group:)
if !entry_group.empty?
Rails.logger.warn("deleting decimations for #{stream.path}")
Rails.logger.debug("deleting decimations for #{stream.path}")
stream.db_decimations.destroy_all #remove existing decimations
end
entry_group.each do |entry|
......
......@@ -14,6 +14,11 @@ development:
database: db/development.sqlite3
timeout: 10000
local:
<<: *default
database: db/local.sqlite3
timeout: 10000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
......
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = false
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :info
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "control_panel_#{Rails.env}"
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
......@@ -44,7 +44,7 @@ Rails.application.configure do
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
config.log_level = :info
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
......
......@@ -19,7 +19,8 @@
development:
secret_key_base: 5378da95ac37be4d4bab4010596a835b639e01dd084ea37e151bf05fc5dec0c6f46f1b162e9325121d757a4683df9880819ba269f488f93a647c935f9b1453d0
local:
secret_key_base: 7c6333cf4833d556c050d005c198903bd5af6377ab706d92c03089ca9a42b3573ec7e5d30f7590214c29775438483fbf82cc12dae5f1cf396441b28fc1d64e81
test:
secret_key_base: 4bb907a33b2b802d006591923f59fa1d0c355f0005dea53efee24b842b17b6b2addd264b20d2d51283c7a0d291efe6888cd1c7e1959f07ccb56304a713696b1e
......
......@@ -16,7 +16,7 @@ DatabaseCleaner.clean
# create named users
def create_user(first_name, last_name)
FactoryGirl.create(:confirmed_user,
FactoryGirl.create(:user,
first_name: first_name,
last_name: last_name)
end
......
require 'factory_girl_rails'
ADMIN_NAME="admin"
ADMIN_PASSWORD ="password"
ADMIN_EMAIL ="admin@wattsworth.local"
namespace :local do
desc "Setup and standalone systems running Lumen API"
task :bootstrap => :environment do
# Create an admin user"
@admin = User.find_by_email(ADMIN_EMAIL)
if(@admin.nil?)
puts 'Creating new admin user'
@admin = FactoryGirl.create(:user,
first_name: 'John',
last_name: 'Doe',
password: ADMIN_PASSWORD,
password_confirmation: ADMIN_PASSWORD,
email: ADMIN_EMAIL)
end
@installation = Nilm.find_by_url("http://localhost/nilmdb")
if(@installation.nil?)
puts 'Creating new local installation'
#create a local installation
nilm_creator = CreateNilm.new
nilm_creator.run(
name: 'local',
description: 'local database',
url: 'http://localhost/nilmdb',
owner: @admin
)
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment