Example Sinatra app for NearlyFreeSpeech.net (NFSN) using the Thin webserver.
Create a site at NFSN of the type Apache 2.4 Generic. Enable SSH access if it's not already activated, and SSH into the site to execute the following commands:
cd /home/protected/
git clone --depth=1 https://github.com/clpo13/SinatraNFSN.git
cd SinatraNFSN
bundle install --path ~/.gem
In the NFSN site control panel, add a daemon with these settings:
- Tag:
sinatra
- Command Line:
/home/protected/SinatraNFSN/run.sh
- Working Directory:
/home/protected/SinatraNFSN/
- Run Daemon As:
me
Add a proxy with the default settings:
- Protocol:
HTTP
- Base URI:
/
- Document Root:
/
- Target Port:
8080
That's it! The daemon will start automatically after it's created. If there are no problems, you should see the words "Hello, world! This is Sinatra x.y.z." at the site's web address.
Check the file /home/logs/daemon_sinatra.log
for log and error messages. Most importantly, make sure the daemon is running as "me" not "web". Otherwise, Ruby will fail to find the right gems and give an error on starting the server. Also check that the proxy port is the same as what Sinatra/Thin is listening on.
The app might break on NFSN realm updates. If you're getting errors about an incorrect bundler version, even when running bundle update --bundler
, try deleting Gemfile.lock and running bundle install --path ~/.gem
again.
This code is made available under the MIT license. Feel free to use and adapt it however you see fit.