i have problem with starting my app, after restart or change someting in my code - app runs and freeze for 15-20 seconds and then run normally, what its can be a problem ?
I've tried eager loading and its not working..
=> Booting Puma
=> Rails 5.2.0 application starting in development
=> Run `rails server -h` for more startup options
[83835] Puma starting in cluster mode...
[83835] * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas
[83835] * Min threads: 5, max threads: 5
[83835] * Environment: development
[83835] * Process workers: 5
[83835] * Phased restart available
[83835] * Listening on tcp://localhost:3000
[83835] Use Ctrl-C to stop
[83835] - Worker 0 (pid: 83849) booted, phase: 0
[83835] - Worker 1 (pid: 83850) booted, phase: 0
[83835] - Worker 2 (pid: 83851) booted, phase: 0
[83835] - Worker 3 (pid: 83852) booted, phase: 0
[83835] - Worker 4 (pid: 83853) booted, phase: 0
Started GET "/api/v1/aaa" for ::1 at 2019-09-25 10:35:40 +0200
(3.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
↳ /Users/aa/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.0/lib/active_record/log_subscriber.rb:98
Related
I run this command to start my server
rails s -b 10.x.x.x
then I got this error
[1013] * Puma version: 5.2.2 (ruby 2.6.3-p62) ("Fettisdagsbulle")
[1013] * Min threads: 2
[1013] * Max threads: 2
[1013] * Environment: development
[1013] * Master PID: 1013
[1013] * Workers: 1
[1013] * Restarts: (✔) hot (✖) phased
[1013] * Preloading application
Exiting
Address already in use - bind(2) for "10.x.x.x" port 3000 (Errno::EADDRINUSE)
How do I stop this current running server 10.x.x.x:3000?
There are several utilities to get the PID of a proccess listening on a port.
lsof -i :3000
Will get you the PID and then you can kill it with kill [PID] or force it with kill -9 [PID]
When I lanch the command /home/centos/.rvm/rubies/ruby-3.0.0/bin/bundle exec puma -C /home/centos/app/config/puma.rb in the app folder I get no error :
[145103] Puma starting in cluster mode...
[145103] * Puma version: 5.2.1 (ruby 3.0.0-p0) ("Fettisdagsbulle")
[145103] * Min threads: 1
[145103] * Max threads: 5
[145103] * Environment: production
[145103] * Master PID: 145103
[145103] * Workers: 1
[145103] * Restarts: (✔) hot (✔) phased
[145103] * Listening on unix:///home/centos/app/tmp/sockets/puma.sock
But when I try to start Puma as service service puma start && service puma status I get :
● puma.service - Puma HTTP Server
Loaded: loaded (/etc/systemd/system/puma.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2021-02-15 17:37:24 UTC; 938ms ago
Process: 145289 ExecStart=/home/centos/.rvm/rubies/ruby-3.0.0/bin/bundle exec puma -C /home/centos/app/config/puma.rb (code=exited, st>
Main PID: 145289 (code=exited, status=203/EXEC)
Feb 15 17:37:24 centos-s systemd[1]: puma.service: Main process exited, code=exited, status=203/EXEC
Feb 15 17:37:24 centos-s systemd[1]: puma.service: Failed with result 'exit-code'.
I don't understand why ?
Problem solved, just a too much parenthesis in the config/puma.rb
I'm starting a server on 3000 and it always boots two workers. I kill the pids and then new pids pop up.
I've tried lsof, killing pids and even running a server parent killer program.
=> Booting Puma
=> Rails 5.1.6.1 application starting in development
=> Run `rails server -h` for more startup options
[23820] Puma starting in cluster mode...
[23820] * Version 3.9.1 (ruby 2.3.4-p301), codename: Private Caller
[23820] * Min threads: 5, max threads: 5
[23820] * Environment: development
[23820] * Process workers: 2
[23820] * Preloading application
[23820] * Listening on tcp://0.0.0.0:3000
[23820] Use Ctrl-C to stop
[23820] - Worker 0 (pid: 23982) booted, phase: 0
[23820] - Worker 1 (pid: 23983) booted, phase: 0
I want to start the rails server in production mode as a deamon running a worker cluster. When I start my rails program everything works as expected.
rails s -e production -b 0.0.0.0
=> Booting Puma
=> Rails 5.0.0.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
[12340] Puma starting in cluster mode...
[12340] * Version 3.4.0 (ruby 2.3.0-p0), codename: Owl Bowl Brawl
[12340] * Min threads: 5, max threads: 5
[12340] * Environment: production
[12340] * Process workers: 3
[12340] * Preloading application
[12340] * Listening on tcp://0.0.0.0:3000
[12340] Use Ctrl-C to stop
[12340] - Worker 0 (pid: 12347) booted, phase: 0
[12340] - Worker 1 (pid: 12349) booted, phase: 0
[12340] - Worker 2 (pid: 12353) booted, phase: 0
however when I add the -d rails starts in single mode, confirmed by checking running processes
rails s -e production -b 0.0.0.0 -d
=> Booting Puma
=> Rails 5.0.0.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
checking running processes confirms only one instance is running, not the clustered mode expected.
So, how do I correctly launch with workers as a deamon process?
Any help is much appreciated.
NOTE: I am also running puma_worker_killer for rolling restarts in case that helps.
rails (5.0.0.1)
puma (3.4.0)
puma_worker_killer (0.1.0)
According to the Puma docs, it's recommended that you start with bundle exec puma.
You can then start a cluster like this: puma -t 8:32 -w 3. Where -t is the min:max number of threads and -w is the number of workers.
I would like to run one and the same project twice on the same server. So I defined two environments alpha and beta for this purpose.
alpha should run on port 3000
beta should run on port 4000
Then I try to start the server twice:
$ ruby bin/rails server -b 0.0.0.0 -p 3000 -e alpha --pid tmp/pids/server-alpha.pid
$ ruby bin/rails server -b 0.0.0.0 -p 4000 -e beta --pid tmp/pids/server-beta.pid
Unfortunately one of those servers (the second to start) stops when it recognizes, that there is another instance.
Environment alpha starts:
=> Booting Puma
=> Rails 5.0.0.1 application starting in alpha on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: alpha
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Environment beta starts:
=> Booting Puma
=> Rails 5.0.0.1 application starting in beta on http://0.0.0.0:4000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: beta
* Listening on tcp://0.0.0.0:4000
Use Ctrl-C to stop
Environment alpha restarts (don't know why!):
* Restarting...
=> Booting Puma
=> Rails 5.0.0.1 application starting in alpha on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
A server is already running. Check tmp/pids/server-alpha.pid.
Exiting
Obviously the pid file still exists. But how can I avoid a restart of the server when I start another one? How can I tell rails to delete the pidfile on restart? Or how else could I handle this problem?
You probable have plugin :tmp_restart in your config/puma.rb. Everytime tmp/restart.txt is touched (which is everytime a server starts), the other server restarts.
Just comment the line and it works (you won't be able to restart your rails server by touching tmp/restart.txt anymore).
I'm not sure this will work but try using = after --pid like this
$ ruby bin/rails server -b 0.0.0.0 -p 3000 -e alpha --pid=tmp/pids/server-alpha.pid
$ ruby bin/rails server -b 0.0.0.0 -p 4000 -e beta --pid=tmp/pids/server-beta.pid