portable script deployment

G

greg

I am trying to deploy several ruby scripts in a unix environment. My
goal is to avoid as much as possible any hard-coding of dependencies or
any modifications to scripts to work in the environment and maintain
easy portability to another server unix environment.
Each script will need to load some paths and register an exit routine.
This is what I am thinking of doing right now.
A user will execute the script ./foo or ./bar
Paths specific to this project/deployment should be added, and an exit
routine for this project should be registered.

/foo -> launcher.rb
/bar -> launcher.rb
/lib/foo.rb
/lib/bar.rb

launcher.rb:
# add paths for this project
ENV['PATH'] = ...
# register exit routine to log script execution
at_exit{logging_routine... }
# figure out what script called launcher.rb through $0
require "#{File.split(File.expand_path($0)).join('/lib/')}.rb"
# execute script
main()

So the only requirement that I would make of the script is that it have
a main() routine. It even allows the removal of a shebang. Everything
that needs to be hard-coded would be left to the launcher script. This
approach requires a launcher for each language so that only one
interpreter needs to be spawned to execute one script. Initially, all
scripts would be placed in the ./lib directory, and a rake task would
create needed soft links.

Do you think this is a good system? Is there a better way to accomplish
this?

Thanks,
Greg Weber
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top