Added rake task to start server in a more production-ready manner using Puma; move config values to config directory
This commit is contained in:
parent
39ce636c0a
commit
0927a00960
2
.gitignore
vendored
2
.gitignore
vendored
@ -60,7 +60,7 @@ build-iPhoneSimulator/
|
||||
data/stgm.db
|
||||
|
||||
# Local configuration
|
||||
data/config.yaml
|
||||
config/config.yaml
|
||||
|
||||
# Node modules for Grunt.js
|
||||
node_modules/
|
||||
|
6
Rakefile
6
Rakefile
@ -15,7 +15,11 @@ namespace :db do
|
||||
end
|
||||
|
||||
namespace :server do
|
||||
task :dev do
|
||||
task :start do
|
||||
system("bundle exec puma -C config/puma.rb")
|
||||
end
|
||||
|
||||
task :reload do
|
||||
%x{guard}
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@ require 'yaml'
|
||||
|
||||
class Config
|
||||
|
||||
DEFAULT_CONFIG = 'data/defaults.yaml'
|
||||
DEFAULT_CONFIG = 'config/defaults.yaml'
|
||||
|
||||
def initialize(config_path)
|
||||
@data = YAML::load_file(DEFAULT_CONFIG)
|
||||
|
@ -1,3 +1,7 @@
|
||||
# Load application config
|
||||
require_relative 'app/config.rb'
|
||||
$conf = Config.new(File.join(__dir__, 'config/config.yaml'))
|
||||
|
||||
# Load Sinatra server
|
||||
require_relative './server.rb'
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
stgm:
|
||||
base_directory: '/srv/videos'
|
||||
|
||||
server:
|
||||
address: '127.0.0.1'
|
||||
port: 4567
|
||||
|
||||
database:
|
||||
adapter: 'sqlite'
|
||||
database: 'data/stgm.db'
|
6
config/puma.rb
Normal file
6
config/puma.rb
Normal file
@ -0,0 +1,6 @@
|
||||
# Load application config
|
||||
require './app/config.rb'
|
||||
$conf = Config.new(File.join(__dir__, 'config/config.yaml'))
|
||||
|
||||
bind_address = "tcp://#{$conf.get('server.address')}:#{$conf.get('server.port')}"
|
||||
bind bind_address
|
@ -3,11 +3,6 @@ require 'sequel'
|
||||
require 'sqlite3'
|
||||
require 'sinatra/base'
|
||||
|
||||
require_relative 'app/config.rb'
|
||||
|
||||
# Load configuration file
|
||||
$conf = Config.new(File.join(__dir__, 'data/config.yaml'))
|
||||
|
||||
# Load the Sequel timestamps plugin
|
||||
Sequel::Model.plugin :timestamps
|
||||
# Initialize Sequel gem for database actions
|
||||
@ -48,4 +43,5 @@ class StageManager < Sinatra::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Load controllers
|
||||
Dir.glob('./app/routes/*.rb').each { |f| require f }
|
||||
|
Loading…
Reference in New Issue
Block a user