安装为Ruby gem的系统服务的安装方法 [英] Approach for installing system service implemented as Ruby gem

查看:74
本文介绍了安装为Ruby gem的系统服务的安装方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在远离Ruby多年之后,我又全力以赴,并且刚刚砍掉了我的第一个gem,其中包括一个可执行文件.一切都像魅力一样.

After years of being away from Ruby, I'm back full-force and have just cut my first gem, which includes an executable. Everything works like a charm.

但是,我面临的问题是我还拥有一个守护可执行文件的启动脚本(不是gem istelf的一部分).另外,我还希望启动脚本将可执行文件指向配置,例如/var/

The problem I am facing, however, is that I ALSO have a startup script (not part of the gem istelf) that daemonizes the executable. Additionally, I'd also like for the startup script to point the executable at configuration in a place like /var/

据我所知,rubygems,gemspec等无法指定在安装过程中被吹到系统其他部分的文件(例如,启动脚本到/etc/init.d,以及配置为/var/).如果可以的话,那肯定没有任何意义.

To the best of my knowledge, there's no way with rubygems, gemspec, etc., to specify files getting blown out to other parts of your system during install (e.g. startup script to /etc/init.d, and config to /var/). It certainly wouldn't make sense if you COULD do that.

所以...我的问题是...自动执行类似这样的安装的正确过程是什么?我正在使用RHEL,并且想知道是否应该让我开始制作第一个RPM弄湿我的脚.

So... my question is... what IS the proper procedure for automating the installation of something like this. I'm using RHEL, and am wondering if it's, perhaps, time for me to get my feet wet with making my first RPM.

有什么想法吗?

推荐答案

可以做到这一点.但是,这可能不是推荐的方法.但是可以,可以使用extensions选项在gem安装过程中运行任意代码.

You can do it. However it is probably not quite the recommended approach. But yes it is possible to run arbitary code during gem installation using the extensions option.

RubyGems手册:

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.

只需将所需的任何红宝石代码放入extconf.rb(或等效文件)中即可.

Just place whatever ruby code you need into the extconf.rb (or equivalent) file.

《 RubyGems指南》中构建C扩展的示例:
http://guides.rubygems.org/c-extensions/

Examples for building C-extensions from the RubyGems Guides:
http://guides.rubygems.org/c-extensions/

这篇关于安装为Ruby gem的系统服务的安装方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆