Starting a Thin cluster on Windows - ruby-on-rails

I have a ruby app on my machine that I'm trying to deploy with a batch script. I've got everything up to the server handled. This is what I'm using:
cd to/path/of/app
thin start -p 3001
This works.
cd to/path/of/app
thin start --servers 3
As per http://code.macournoyer.com/thin/usage/, does not work. I get an error "lib/thin/runner.rb:142:in 'parse!': invalid option: --servers"
Any idea why this isn't working?

On line 88 in lib/thin/runner.rb it says # Daemonizing not supported on Windows :(

Related

EC2 : Rails deployment gives blank pages

I have deployed my rails application on EC2. It runs on two servers. One for rails application and second for DB.
When I start application using "rails s -e production&" and if I stay connected using SSH,
I can see the webpages.
As soon as I disconnect SSH I can not see the pages.
There are no errors thrown. One weird thing is "Production.log" file does not have anything.
everything is spit out on console.
You are running rails in the current ssh session. Any programs you have running during that session will stop if you disconnect. You need to set up your rails app to run as a daemon using something like Phusion Passenger.
You are basically running the built in WEBrick server that is not really meant for production so it's likely that the process is getting killed after the parent process (your ssh process) gets terminated.
You can probably tweak the configuration to make WEBrick not quit, or you can simply run your session using screen or tmux
Screen:
$ screen
$ rails s -e production &
$ screen -d
When you want to reattach:
$ screen -r
Tmux:
$ tmux
$ rails s -e production &
$ # Hit <ctrl-b><ctrl-d> to detach
When you want to reattach:
$ screen attach -t 0
Or like #datasage mentioned you can run your Rails with an actual production web server like Passenger Phusion or Unicorn.

How to keep server running on EC2 after ssh is terminated

I have an EC2 instance on which I installed rails server. The server also runs fine when I do
rails server
But after I close the ssh connection the server also stops. How can I keep the server running even after closing the ssh connection.
screen rails s
did the trick
after that CTRL + A + D and I left and the server is running fine
Try this. We have to start rails server as daemon.
rails s -d &
run at as server means thu nginx or apache or what ever this development server not mean run as server
user this is need more info https://www.digitalocean.com/community/articles/how-to-install-rails-and-nginx-with-passenger-on-ubuntu
also if want advance sololtion use rubber https://github.com/rubber/rubber
I needed mine running everything not, just rails in the background. Install Screen which makes a sub terminal that isn't affected by your ssh connection. sudo apt-get install screen Open screen screen Then start rails rails server &.
Press 'Crtl + A' then 'D' to escape and type screen -r to get back in to the screen terminal.
I will recommend using apache or something else instead of the regular rails server but you can probably add & at the end and feel free to leave
rails server &
These steps worked for me. MY OS is Description: Ubuntu 16.04.4 LTS
sudo apt-get install screen
screen rails s
CTRL + A + D from terminal to detached the existing process and let it run.
Here's a production proof version using RVM and Systemd. Will keep the server alive if it gets terminated for any reason.
[Unit]
Description=Puma Control
After=network.target
[Service]
Type=forking
User=user
WorkingDirectory=/var/www/your_project_name
PIDFile=/var/www/your_project_name/shared/tmp/pids/puma.pid
ExecStart=/home/user/.rvm/bin/rvm default do bundle exec puma -C /var/www/your_project_name/shared/puma.rb --daemon
ExecStop=/home/user/.rvm/bin/rvm default do bundle exec pumactl -S /var/www/your_project_name/shared/tmp/pids/puma.state -F /var/www/your_project_name/shared/puma.rb stop
Restart=always
# RestartSec=10
[Install]
WantedBy=default.target

Run thin as webservice Ruby 1.9.3, Windows Server 2003

I'm trying to run a ruby app (redmine) as thin webservice on Windows Server 2003. I've already read and done everything said here and here, but it still won't work. At the moment I've set:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[my_service_name]\Parameters]
Application=c:\ruby\bin\ruby.exe
AppDirectory="c:\Program Files\redmine-1.4-test"
AppParameters=c:\ruby\bin\thin start -p 3001 -e development
Running thin from command line via:
C:\Program Files\redmine-1.4-test>thin start -p 3001 -e development
works fine.
I already tested moving Redmine to a path with no spaces, which doesn't change anything.
Any idea what can be wrong? Any hints how I could track the problem down?
Make sure that you are running the new service in the account where Ruby is installed - where you can run thin normally from the command line. Edit the service from the Control Panel (services.msc) and set up the Logon tab accordingly.

How to start Thin server automatically when System Re boots

How to start thin Server automatically when Server Reboots.
I have a Rails 3 project which uses Thin Server.I can manually control the thin Server from terminal.Is it possible to start thin server as background process when system reboots.
Thanks in advance.
You can use Scheduled Tasks. There's a specific trigger option for starting a task when the computer starts.
To start the process in background mode you can use the -d option of the rails command.
I suppose you need to do this:
sudo thin install #to create init.d entry for thin
sudo /usr/sbin/update-rc.d -f thin defaults # to setup it
sudo thin config -C /etc/thin/<appname>.yml -c /var/rails/<appdir> --servers 4 -e production # to generate congig file for it. If you already got config file, you can just copy it to /etc/thin/ instead of creating.
If you use rvm on your server - browse this: RVM and thin, root vs. local user.
You can also take a look at: https://github.com/opscode-cookbooks/runit

Can't Get Mongrel_Service Gem to Start Mongrel as a Windows Service

I’m more or less a newb to Ruby on Rails, but I’ve been tasked with debuging a Rails app that guy that’s no longer around wrote. The app is running on a manchine using:
• Windows XP Professional
• Apache 2.2
• Rails 2.3.8
• mongrel (1.1.5 x86-mingw32)
• mongrel_service (0.3.4 i386-mswin32)
I copied the app from the server and did some debugging on it on my personal machine. I just setup a Git repository on my personal machine and cloned it back over to the server. Everything seems to be working great except mongrel_service doesn’t work anymore. Each time I try to start the service from Windows “Services” tool I get this error:
The MYAPP_Mongrel_As_Service service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service
I tried removing the service with:
C:\MyApp>mongrel_rails service::remove --name MYAPP_Mongrel_As_Service
Stopping MYAPP_Mongrel_As_Service if running...
MYAPP_Mongrel_As_Service service removed
and reinstalling it with:
C:\MyApp>mongrel_rails service::install --name MYAPP_Mongrel_As_Service -c "C:\MyApp" --port 3001 --env
ironment production --address localhost --log "log\mongrel_as_service.log" --pid "tmp\pids\mongrel_a
s_service.pid"
MYAPP_Mongrel_As_Service service created.
But no matter how many times I try, or what options I use, I can’t get the service to run. What’s weird is that I can get mongrel to startup by itself just fine.
C:\MyApp>mongrel_rails start -c c:\MyApp --port 3001 --environment production --address localhost --
g "c:\MyApp\log\mongrel_as_service.log" --pid "C:\MyApp\tmp\pids\mongrel_as_service.pid"
** Starting Mongrel listening at localhost:3001
** Starting Rails with production environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. INT => stop (no restart).
** Mongrel 1.1.5 available at localhost:3001
** Use CTRL-C to stop.
It just won’t work when I try to start it as a service. I've done a lot of googling on the subject, but I can't find anything to fix the problem. It's odd that it was working before but now it doesn't. There must be something wrong with my service::install line because I can't get the original unedited Rails app to work with mongrel_as_service either.
I figured it out. It turns out that the log file for mongrel_service didn't exist on my file. To fix the problem, I just made a blank text file and renamed it to the name of my log file. It worked like a charm. It's odd that mongrel_service doesn't make it's own log file if it can't detected it, but oh well.

Resources