Ruby LSAPI Installation/Upgrade⇑
The easiest way to install Ruby LSAPI is as a gem:
gem install ruby-lsapi
To upgrade, just reinstall Ruby LSAPI as a gem.
Ruby LSAPI Administration⇑
Setting up Ruby applications is as easy as plugging the application's information into a Ruby context. Below is a brief description of the steps for setting up a Ruby application: (More detailed guides can be found in our wiki.)
- Add a virtual host and a Rack/Rails context: The easiest way to do this is to add a member virtual host to the EasyRailsWithSuEXEC virtual host template. (Go to the Virtual Host Templates tab, in the WebAdmin console under Configuration.) Virtual hosts using this template already have a Rack/Rails context with the Ruby application's URI set to "/".
- Graceful restart to apply changes: (WebAdmin console > Actions > Graceful Restart) Scripts with the suffix you defined in the script handler will now use the external application you created.
Ruby LSAPI Configuration⇑
External Application Settings
Much of your Ruby settings are controlled by your Rack/Rails settings (WebAdmin console > Configuration > Rack/Rails) and in each individual Rails/Rack context. These settings are explained in the LiteSpeed Web Server documentation.
Environment Variables
Ruby LSAPI applications can be further configured using the environment variables listed below:
LSAPI_CHILDREN (default: 0) |
LSAPI allows a variety of setups. Two of these setups, Worker and ProcessGroup can be set using this environment variable. (Note: In previous versions of this documentation, Worker was referred to as "server managed mode" and ProcessGroup referred to as "self managed mode".) Setting Setting |
LSAPI_AVOID_FORK (default: 0) |
When set to 0, the internal process manager will not try to avoid forking new processes. To save system resources, it will stop processes when they finish and only start child processes when they are needed. This is often preferred in shared hosting. When set to 1, the internal process manager will try to avoid frequently stopping and starting child processes. This might be preferred in a dedicated hosting environment because it may be faster to recycle existing processes, even if it means running processes when they are unused sometimes. |
LSAPI_EXTRA_CHILDREN (default: 1/3 of LSAPI_CHILDREN or 0) |
In ProcessGroup mode, |
LSAPI_MAX_REQS (default: 10000) |
In ProcessGroup mode, this controls how many requests each child process will handle before it exits automatically. This parameter can help reduce memory usage by leaky Ruby functions. |
LSAPI_MAX_IDLE (default: 300 seconds) |
In ProcessGroup mode, |
LSAPI_MAX_IDLE_CHILDREN (default: 1/3 of LSAPI_CHILDREN or LSAPI_CHILDREN) |
In ProcessGroup mode, |
LSAPI_MAX_PROCESS_TIME (default: 3600 seconds) |
In ProcessGroup mode, |
LSAPI_PGRP_MAX_IDLE (default: FOREVER ) |
In ProcessGroup mode, |
LSAPI_PPID_NO_CHECK |
By default, an LSAPI external application will exit automatically if the parent process dies. This is to reduce orphan processes when the web server is restarted. However, it may be desirable to disable this feature in situations such as when an LSAPI process was started manually from the command line. Adding the |
LSAPI_ALLOW_CORE_DUMP |
By default, an LSAPI application will not leave a core dump file when it crashes. If you want to have LSAPI dump a core file, you should add this environment variable and set to 1. If set, core files will be created under the current working directory, generally the directory of the Ruby script that crashed. To turn off this setting, remove the environment variable completely. |