Coder Social home page Coder Social logo

rubyservice's Introduction

License: MIT

Ruby Service for Windows Continuous Integration Status

A simple ruby server for windows.

Suggestions, possibilities for improvement, requests, love letters...

Don't hesitate to submit your suggestions in the github issue-tracker here.

How to get it

From Travis-CI build artifacts, if Travis would kindly publish the build artifacts, which it does not. Otherwise, clone/download the zipball & compile with Visual-Studio or MonoDevelop/XBuild/XamarinStudio if you use Mac or Linux. If you use Windows, Visual Studio Community Edition is free as in beer, by the way.

How to use it

Installing it as windows-service

    sc create "COR_Redmine" displayname= "Redmine Puma" start= auto binPath= "C:\Redmine\redmine-3.2.4\StartRuby.exe"
    sc description "COR_Redmine" "Puma Web-Server serving redmine"
    sc config "COR_Redmine" depend= <Dependencies(separated by / (forward slash))>

note that you are expected to set the necessary dependencies yourselfs, as the name of your MSSQL-Server instance is not constant.

To delete the service:

    sc delete "COR_Redmine"

To manually start/stop the service, type

    services.msc

into Windows the "run" prompt.

To start/stop the service from command-line:

    net start "COR_Redmine"
	net stop "COR_Redmine"

or with the newer sc command, which also works over network:

    sc start "COR_Redmine"
	sc stop "COR_Redmine"

See also Difference between net and sc.

Configuration

XML-configuration

A few config variables are needed

  • The config file has to be called the same as the service-executable, minus .exe and plus .json.config, and has to be in the same directory as the serice-.exe-file
  • The logfile-directory is where the service will log all output, in a separate file for each day - no autocleaning.
  • The WebRoot (your web application's root folder)
  • DateTimeFormat, that will be used when writing text into the logfile(s)
  • The RAILS_ENV environment variable
  • The path to Ruby.exe, to be appended to the PATH environment variable
  • StartProgram: The server you want to start (e.g. puma, thin, webrick, whatever)
  • The command line arguments for the server.

Example:

REM {StartProgram} --env production --dir "{WebRoot}" -p 3000
REM e.g. 
SET RAILS_ENV="production";
SET PATH="%PATH%;C:\Ruby21-x64\bin;"
puma --env production --dir "C:\Redmine\Redmine-3.2.4" -p 3000 >> "C:\Redmine\redmine-3.2.4\Log\service_20161220.log"

the corresponding configuration file would be:

{
  "LogFile_Directory": "C:\\Redmine\\redmine-3.2.4\\Log\\",
  "WebRoot": "C:\\Redmine\\redmine-3.2.4",
  "DateTimeFormat": "dddd, dd.MM.yyyy HH:mm:ss",

  "OverwriteEnvironmentVariables": {
    "RAILS_ENV": "production"
  },

  "AppendEnvironmentVariables": {
    "PATH": "C:\\Ruby21-x64\\bin"
  },

  "StartProgram": "puma",
  "StartProgramArguments": "--env production --dir \"{WebRoot}\" -p 3000"
}

How to integrate with IIS:

If you used the above config-file to launch Redmine, then you'll have redmine running on http://127.0.0.1:3000

You can now reverse-proxy redmine into IIS. E.g. create the directory "C:\inetpub\wwwroot\redmine", and put the below XML into a file called "web.config". Now, you need to open inetmgr, and convert the directory "redmine" into a web-application. Enable proxy on this machine, under "Application request routing".

You will need to install the Application-Request-Routing and the URL-Rewrite module for IIS first. See that you download the latest version, otherwise installation will fail with the latest IIS versions.

Note: Microsoft apparently is not capable to write a proper reverse-proxy/url-rewrite module. So if you have redmine running in a virtual directory "redmine" in IIS (e.g. http://localhost/redmine), then redmine itselfs should also run in a virtual directory called "redmine" on 127.0.0.1:3000, e.g. http://127.0.0.1:3000/redmine. If it runs in the root domain (http://localhost), then it should run in the root-domain as well (http://127.0.0.1:3000). The web.config file here assumes that the ruby web-server runs under http://127.0.0.1/redmine.

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
  
    <system.web>
      <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://127.0.0.1:3000/redmine/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
    
</configuration>

Check out http://127.0.0.1:3000/redmine first to see whether the ruby webserver actually works. It should. Then check out http://localhost/redmine to see if the reverse-proxy works. It should.

Note that you need to enable virtual directories in the redmine source-code, e.g. you need to change config.ru to

#map ENV['RAILS_RELATIVE_URL_ROOT'] do
map Rails.application.config.relative_url_root || "/" do
    run RedmineApp::Application
end

and add

  config.relative_url_root = '/redmine'

to C:\Redmine\redmine-3.2.4\config\environments\production.rb

rubyservice's People

Contributors

ststeiger avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.