diff --git a/.gitignore b/.gitignore index 5ac23c9..f532c52 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /config/database.yml /config/initializers/secret_token.rb /config/master.key +/config/puma.rb # Ignore all logfiles and tempfiles. /log/* diff --git a/README.md b/README.md index 6cd1b67..5191fb2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ Quantified self * System dependencies: none +## Installation + + git clone https://gitea.michalczyk.pro/fixin.me/fixin.me.git + bundle config set --local path '.gem' + bundle install + + ## Configuration cp -a config/application.rb.dist config/application.rb @@ -15,7 +22,7 @@ Modify configuration settings below `SETUP` comment appropriately. ## Database -Create database user and grant privileges: +Grant database user and privileges: > mysql -p mysql> create user fixinme@localhost identified by ''; @@ -33,7 +40,41 @@ Run database creation and migration tasks: ## Running -Apache configuration for: Puma+mod_proxy, mod_passenger ... + +### Standalone Rails server + Apache proxy + +Copy Puma config template: + + cp -a config/puma.rb.dist config/puma.rb + +and specify server IP/port, either with `port` or `bind`, e.g.: + + bind 'tcp://0.0.0.0:3000' + +Run server + + RAILS_ENV="production" bin/rails s -## How to run the test suite: ... +### Apache mod_passenger + + +## Contributing + + +### Database + +Grant database user privileges for development and test environments, +possibly with different Ruby versions: + + > mysql -p + mysql> create user `fixinme-dev`@localhost identified by ''; + mysql> grant all privileges on `fixinme-%`.* to `fixinme-dev`@localhost; + mysql> flush privileges; + + +### Environment + +Use `RAILS_ENV="development"` for rake commands and running rails server. + +Use `RAILS_ENV="test"` for running tests. diff --git a/config/puma.rb.dist b/config/puma.rb.dist new file mode 100644 index 0000000..daaf036 --- /dev/null +++ b/config/puma.rb.dist @@ -0,0 +1,43 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart