Approach for installing a system service implemented as a Ruby gem

After years of being away from Ruby, I am back at full strength and just cut my first gem, which includes an executable. Everything works like a charm.

The problem I am facing is that I ALSO have a script run (not the gem istelf part) that demonizes the executable. In addition, I would like the script to indicate the executable file in the configuration at a place like / var /

As far as I know, in Rubygems, gemspec, etc. There is no way to specify files that will be deleted to other parts of your system during installation (for example, running a script in /etc/init.d and config to / var /). Of course, this does not make sense if you CAN do it.

So ... my question is ... what is the right procedure to automate the installation of something like that. I use RHEL, and I wonder if it is time for me to keep my feet wet by making my first RPM.

Any thoughts?

+3
source share
1 answer

You can do it. However, this is probably not a highly recommended approach. But yes, perhaps using the option extensionsyou can execute arbitrary code during the installation of gem.

From the RubyGems Guide :

Usage
  spec.extensions << 'ext/rmagic/extconf.rb'

Notes
These files will be run when the gem is installed, causing the 
C (or whatever) code to be compiled on the user’s machine.

Just put the ruby ​​code you need in the file extconf.rb(or equivalent).

C- RubyGems:
http://guides.rubygems.org/c-extensions/

+2

Source: https://habr.com/ru/post/1614720/


All Articles