How to run Sidekiq on Windows - ruby-on-rails

Today im trying to setup my windows 10 machine with all my Rails environment. While trying to run the bundle exec sidekiq command to boot up Sidekiq i get the following error:
It seems that 'daemon() function is not implemented on this machine'. My first guess is that a process in windows does not run as daemon but does as a service?
Environment:
Windows 10
Ruby 2.3.0 x64
Devkit
Tried also dropping the -d option but i get the same error.

You can't daemonize on Windows. Daemonizing is a legacy option for older Unix systems that only support init.d, no modern systems recommend using it anymore.

Related

Use RubyMine and Docker for development

I'm trying to develop a Rails project without having to install Ruby and all server tools in my Windows local machine. I've created my Docker containers (Ruby and MySQL) and installed the Docker plugin on RubyMine 2016.1, however it seems not very practical for the development daily use, I mean the cycle develop, run, debug, just before deployment to test server.
Am I missing something to make this workflow possible? Or isn't Docker suggested for this step in the development process?
I don't develop under Windows, but here's how I handle this problem under Mac OS X. First off, my Rails project has a Guardfile set up that launches rails (guard-rails gem) and also manages running my tests whenever I make changes (guard-minitest gem). That's important to get fast turnaround time in development.
I launch docker daemonized, mounting a local directory into the docker image, with an exposed port 3000, running a never-ending command.
docker run -d -v {local Rails root}:/home/{railsapp} -p 3000:3000 {image id} tail -f /dev/null
I do this so I can connect to it with an arbitrary number of shells, to do any activities I can only do locally.
Ruby 2.2.5, Rails 5, and a bunch of Unix developer tools (heroku toolbelt, gcc et al.) are installed in the container. I don't set up a separate database container, as I use SQLite3 for development and pg for production (heroku). Eventually when my database use gets more complicated, I'll need to set that up, but until then it works very well to get off the ground.
I point RubyMine to the local rails root. With this, any changes are immediately reflected in the container. In another command line, I spin up ($ is host, # is container):
$ docker exec -it {container id} /bin/bash
# cd /home/{railsapp}
# bundle install
# bundle exec rake db:migrate
# bundle exec guard
bundle install is only when I've made Gemfile changes or the first time.
bundle exec rake db:migrate is only when I've made DB changes or the first time.
At this point I typically have a Rails instance that I can browse to at localhost:3000, and the RubyMine project is 'synchronized' to the Docker image. I then mostly make my changes in RubyMine, ignoring messages about not having various gems installed, etc., and focus on keeping my tests running cleanly as I develop.
For handling a console when I get exceptions, I need to add:
config.web_console.whitelisted_ips = ['172.16.0.0/12', '192.168.0.0/16']
to config/environments/development.rb in order for it to allow a web debug console when exceptions happen in development. (The 192.168/* might not be necessary in all cases, but some folks have run into problems that require it.)
I still can't debug using RubyMine, but I don't miss it anywhere near as much as I thought I would, especially with web consoles being available. Plus it allows me to run all the cool tools completely in the development environment, and not pollute my host system at all.
I spent a day or so trying to get the remote debugger to work, but the core problem appears to be that (the way ruby-debug works) you need to allow the debugging process (in the docker container) to 'reach out' to the host's port to connect and send debugging information. Unfortunately binding ports puts them 'in use', and so you can't create a 'listen only' connection from the host/RubyMine to a specific container port. I believe it's just a limitation of Docker at present, and a change in either the way Docker handles networking, or in the way the ruby-debug-ide command handles transmitting debugging information would help fix it.
The upshot of this approach is that it allows me very fast turnaround time for testing, and equally fast turnaround time for in-browser development. This is optimal for new app development, but might not work as well if you have a large, old, crufty, and less-tested codebase.
Most/all of these capabilities should be present in the Windows version of Docker, as well.

Deploy Ruby on Rails application in a Windows Server 2012

I have read about how to deploy a Ruby on Rails in Windows, some of them about Windows Server and IIS.
I downloaded Rubyinstaller and its Dev-Kit in my developer pc to develop my application, however I don't know how to use it with Apache instead the embed WEBrick server. Some people have pointed that using Passenger Gem is not a good idea in terms of performance, but those posts that I found are before 2012 or older.
I would like to know how to deploy a RoR application (Rails 4.x, Ruby 2.x) in a production server with Windows Server 2012 and XAMPP (Apache), without breaking most of the current configuration, preferably not using IIS.
I also found a Bitnami installer with the Ruby Stack. I could customize the installation deselecting those components that I already have or I don't need, like Git, PHP, MySQL, etc. but installation of Apache in this installer is mandatory, so, is there any chance to avoid breaking my current installation/configuration of Apache (installed by another Bitnami XAMPP installer)? I already have an Apache/PHP installation that I don't want to break.
Based on your requirements I would run the app in Docker on azure/windows server.
Or try puma, using this windows install tutorial https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows.
Ideally, you'd just use Docker and run the app in a linux container to avoid all the potential problems. However, since Windows Server 2012 lacks native support for containers, I don't think you can have Docker running directly on this windows server.
So, instead, I'd suggest adding an extra layer in between - deploying a linux VM which has Docker installed and contains a Docker image which contains your application to the windows server.
The are a couple of ways I see fit is to host your app in IIS. The only problem is that IIS does not have a native way to host Rails app. OPTION 1 - We used Rails on an existing IIS web infrastructure using Mongrel:http://www.napcsweb.com/howto/rails/deployment/railsonIISWithMongrel.pdf
Or
Option 2 using Mongrel without IIS like so:
install rails and mongrel
gem install rails –include-dependencies
gem install mongrel –include-dependencies
serve rails app
rails app
or
ruby server 0e production -p 4001
check you can acceess the site
press ctrl-c to exit
Install Mongrel as a service
mongrel_rails_service install –n rails_app –p 4001
start the rails_app service from services.msc
From the original rails documentation you have more options to host your ruby app on production:
http://weblog.rubyonrails.org/2006/5/11/deploying-rails-on-windows-servers/

Setup rubymine to execute commands over ssh

I'd like to setup a rails development environment where everything is running in a Ubuntu VM but I use windows 7 for display.
Under ububtu (Which is a virtualbox VM)
ruby
rails environment (rvm, rails, rails webserver...)
git
Under Windows (native OS)
browser
IDE
I SSH into the VM for executing commands, and files are shared with nfs.
Everything works great, but I would like to try RubyMine as my editor. So in this setup I have two choices:
Install RubyMine on windows, and configure it so it executes it's commands in the VM via SSH.
Install RubyMine on ubuntu, and display it in windows with a X server running on windows (such as Xming) : rubymine --display windows_ip:0
So my question is : Is it possible to configure rubyMine so that it executes commands via SSH ?
I have seen this feature request, so my guess it that it's not currently possible.
Currently we're working on this feature and it will be available in the next 5.0 EAP

deploy ruby or rails on windows [duplicate]

I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.

Delay when issuing any rails commands on windows vista

Everytime I run any rails command on my windows vista dev box there is always something like a 30 second delay before the command does anything. I don't have the firewall enabled and the virus protection is disabled. Any thoughts on what could be causing this?
Thanks
I can't comment on this specific issue, but I can say I had nothing but problems trying to run Rails on Windows in the past. That said, after trying Ubuntu and MacOs, I still prefer to use Windows as my primary UI. My solution is to run Ubuntu Server on a VM, and use a Samba file share to access dev files, with putty as my primary console interface. The linux command line is far more powerful, and is where the Rails ecosystem is really geared to be running.
VirtualBox: http://virtualbox.com
Ubuntu: http://ubuntu.com
Samba: http://www.samba.org/
Putty: http://www.chiark.greenend.org.uk/~sgtatham/putty/
With these tools, you can run your Rails stack in a nice linux server environment, and still enjoy the utility and functionality of the Windows GUI. (Although I'd recommend you move from Vista to 7)

Resources