Trying to install Redmine 2.0 on a windows 2008 server as a service
Added by steve parry over 12 years ago
Hi all,
for the last day i've been trying to install Redmine 2.0 on a windows 2008 server as a service.
Ive followed the following guide https://sites.google.com/site/alensit/software-tools/redmine#TOC-Running-under-Mongrel
which seems to be more orientated towards older versions, so I started using certain commands out of http://www.redmine.org/projects/redmine/wiki/RedmineInstall
now ive got redmine to work at command line, but mongrel wont work.
I've found articles that say to install the prelease version of mongrel which did get me further.
but now mongrel_service is throwing errors
Command is
mongrel_rails service::install --name redmine_service
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_ conflicts': Unable to activate mongrel_service-0.4.beta3, because mongrel-1.2.0. pre2-x86-mingw32 conflicts with mongrel (~> 1.1.5) (Gem::LoadError) from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:i n `activate' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:212:in `rescue in t ry_activate' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb:209:in `try_activat e' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:i n `rescue in require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:i n `require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mongrel_service-0.4.beta3/lib/m ongrel_service/init.rb:6:in `<top (required)>' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i n `require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i n `require' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin .rb:134:in `block in load' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:214:in `each' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:214:in `each' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb:63:in `bl ock (2 levels) in deprecate' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin .rb:112:in `load' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/ bin/mongrel_rails:279:in `<top (required)>' from C:/Ruby193/bin/mongrel_rails:23:in `load' from C:/Ruby193/bin/mongrel_rails:23:in `<main>'
any ideas on how i can fix this.
Replies (6)
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by Etienne Massip over 12 years ago
For what is worth, I've dropped using Mongrel and Mongrel service gems which are both not maintained anymore and switched to Puma and to a win32-service
custom made service.
That said, if your Mongrel setup is working by command line, the custom made service could be enough if you replace the rails s puma by some rails s mongrel or whatever.
After gem install win32-service
, drop the below code in a service.rb
file and just, e.g., sc create redmine binPath="C:\Ruby193\bin\rubyw -C D:\redmine\ service.rb"
(AFAIR it well).
REDMINE_DIR = 'D:\redmine'
LOG_FILE = "#{REDMINE_DIR}\\log\\service.log"
begin
require 'win32/daemon'
include Win32
class RedmineService < Daemon
def service_init
File.open(LOG_FILE, 'a'){ |f| f.puts "Initializing service #{Time.now}" }
@server_pid = Process.spawn 'rails s puma -e production', :chdir => REDMINE_DIR, :err => [LOG_FILE, 'a']
end
def service_main
File.open(LOG_FILE, 'a'){ |f| f.puts "Service is running #{Time.now} with pid #{@server_pid}" }
while running?
sleep 10
end
end
def service_stop
File.open(LOG_FILE, 'a'){ |f| f.puts "Stopping server thread #{Time.now}" }
system "taskkill /PID #{@server_pid} /T /F"
Process.waitall
File.open(LOG_FILE, 'a'){ |f| f.puts "Service stopped #{Time.now}" }
exit!
end
end
RedmineService.mainloop
rescue Exception => e
File.open(LOG_FILE,'a+'){ |f| f.puts " ***Daemon failure #{Time.now} exception=#{e.inspect}\n#{e.backtrace.join($/)}" }
raise
end
Rude and quick dirty code though, might have some issue when stopping service but it works.
Also note that I'm not even sure that the PID in Windows is unique.
Hope it helps.
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by steve parry over 12 years ago
Thanks for the reply.
I now have redmine running in puma.
but the script you provided wont seem to run as a service or at the command prompt.
It will run with slight modification in the ruby shell. the 'rails' file is located in the .\script folder
REDMINE_DIR = 'C:\redmine-2.0' LOG_FILE = "#{REDMINE_DIR}\\log\\service.log" begin require 'rubygems' require 'win32/daemon' include Win32 class RedmineService < Daemon def service_init File.open(LOG_FILE, 'a'){ |f| f.puts "Initializing service #{Time.now}" } @server_pid = Process.spawn 'rails s puma -e production', :chdir => "#{REDMINE_DIR}\\Script" #, [:out, :err] => [LOG_FILE, 'a'] end def service_main File.open(LOG_FILE, 'a'){ |f| f.puts "Service is running #{Time.now} with pid #{@server_pid}" } while running? sleep 10 end end def service_stop File.open(LOG_FILE, 'a'){ |f| f.puts "Stopping server thread #{Time.now}" } system "taskkill /PID #{@server_pid} /T /F" Process.waitall File.open(LOG_FILE, 'a'){ |f| f.puts "Service stopped #{Time.now}" } exit! end end RedmineService.mainloop rescue Exception => e File.open(LOG_FILE,'a+'){ |f| f.puts " ***Daemon failure #{Time.now} exception=#{e.inspect}\n#{e.backtrace.join($/)}" } raise end
The entries in the service.log file
Initializing service 2012-05-17 10:03:27 +0100 ***Daemon failure 2012-05-17 10:03:27 +0100 exception=#<Errno::ENOEXEC: Exec format error - rails s puma -e production> C:/redmine-2.0/service.rb:15:in `spawn' C:/redmine-2.0/service.rb:15:in `service_init' C:/redmine-2.0/service.rb:34:in `mainloop' C:/redmine-2.0/service.rb:34:in `mainloop' C:/redmine-2.0/service.rb:34:in `<main>'
Any ideas?
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by Etienne Massip over 12 years ago
rails
is here the command located in the MRI bin
dir itself added to the %PATH%
. You can have removed it accidently when uninstalling the railties
gem in which case you might want to install it again to have the command back?
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by steve parry over 12 years ago
Thanks for the reply.
I've got it running using the old srvany.exe routine.
Seems to be working fine
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by Olivier Franceschi about 12 years ago
Hello,
Can't get rid of this ENOEXEC: Exec format error - rails s puma -e production.
Can you please explain a bit more how to solve it.
RE: Trying to install Redmine 2.0 on a windows 2008 server as a service - Added by Etienne Massip about 12 years ago
You should try to run the command from an interactive interpreter.
ruby script/rails s puma -e production
is a safer syntax.