FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

thin install - systemD support by strelec · Pull Request #184 · macournoyer/thin · GitHub

This repository was archived by the owner on Jul 15, 2026. It is now read-only.
/ thin Public archive

thin install - systemD support - #184

Open
strelec wants to merge 1 commit into
macournoyer:masterfrom
strelec:master
Open

thin install - systemD support#184
strelec wants to merge 1 commit into
macournoyer:masterfrom
strelec:master

Conversation

strelec commented Jul 4, 2013

Copy link
Copy Markdown

As discussed on google groups, many modern linux systems have migrated from old SystemVinit to SystemD, which makes our install script outdated

This is the commit that autodetects which one of them is in use and make the change appropriately.

p.s.: I have tried to conform to the existing coding style.

Copy link
Copy Markdown

Are you your service is working fine? I tried your service file and it didn't work. I'm currently investigating.

Copy link
Copy Markdown
Owner

@pothibo did you get it working? If you got a working config, I'll integrate it into Thin.

Copy link
Copy Markdown

Sorry I forgot about it. The issue with systemd and ruby is that there are tools like rvm, rbenv and such that handles ruby version. This is what was going on with my system.

I'm not sure what the best approach would be. Maybe you can give me some idea?

Right now, here's the service I'm using.

[Unit]
Description=lamarmite.ca Thin instance
After=syslog.target network.target

[Service]
Type=simple
User=marmite
Group=http
Environment="PATH=/usr/local/share/npm/bin:/opt/rubies/ruby-2.0.0-p247/bin:$PATH"
WorkingDirectory=/home/marmite/
ExecStart=/home/marmite/.gem/ruby/2.0.0/bin/thin start --ssl -R /srv/http/marmite.ca/config.ru -e production

[Install]
WantedBy=multi-user.target

pirj commented Dec 3, 2013

Copy link
Copy Markdown

I would prefer starting thin in userspace, e.g. systemctl enable --user thin-marmite. This will allow running several thin servers on a single machine under different users, and there's no chance a security flaw in Rails or whatever will allow it taking the control over all the machine or even get to other app's data.

Copy link
Copy Markdown

@pirj it was my understanding that setting a user & group would run the service as the specified user/group.

pirj commented Dec 4, 2013

Copy link
Copy Markdown

@pothibo Makes sense

pirj commented Dec 4, 2013

Copy link
Copy Markdown

I suggest file format strongly depends on how gems are bundled and is rvm installed.
I don't see any need in rvm in production, and install gems in the following way:

gem install bundler
PATH=$PATH:/home/app/.gem/ruby/2.0.0/bin
bundle install --path ~/.gem

The following webapp.service works fine (start, stop, restart):

[Unit]
Description=Web application server
After=network.target

[Service]
Type=forking
User=app
PIDFile=/home/app/webapp.pid
ExecStart=/home/app/.gem/ruby/2.0.0/bin/thin -d --user app -e production --chdir /home/app/app --socket /home/app/webapp.sock --pid /home/app/webapp.pid --log /home/app/log/webapp.log start
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -QUIT $MAINPID

[Install]
WantedBy=multi-user.target

If I set Type=simple, it just doesn't start.

Should it listen to unix socket or port by default? Can we do both? Or is it a good idea to insist on socket usage?
What to do with people passionate about rvm on production? No idea here.

Copy link
Copy Markdown

Honestly, I have no idea, I meant to submit a PR here for a long time, but there's two things that are bothering me.

ExecStart needs to include absolute path.
User/Group should be set to the user/group your web service runs on

Maybe it should try to find the correct paths and ask for the user for a confirmation?
And then ask the user for user/group?

I guess @macournoyer would be better positionned to answer those questions though.

Copy link
Copy Markdown

@pothibo If you're using with rvm, rather than handling with 'thin install', you should follow this guide - http://rvm.io/deployment .

Copy link
Copy Markdown

FYI this systemd service works perfectly for me:

[Unit]
Description=A fast and very simple Ruby web server
After=syslog.target network.target

[Service]
Type=forking
User=www-data
Group=www-data
ExecStart=/usr/local/bin/thin start --all /etc/thin/
ExecReload=/user/local/bin/thin restart --all /etc/thin/
ExecStop=/usr/local/bin/thin stop --all /etc/thin
TimeoutSec=300

[Install]
WantedBy=multi-user.target

Copy link
Copy Markdown

hi, any news about this?

ioquatix commented Sep 7, 2020

Copy link
Copy Markdown
Collaborator

Can you please rebase this on master.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL