portable script deployment

Discussion in 'Ruby' started by greg, Oct 4, 2006.

  1. greg

    greg Guest

    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
    greg, Oct 4, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eli Bendersky
    Replies:
    1
    Views:
    1,152
    Mike Treseler
    Mar 1, 2006
  2. Benny Ng
    Replies:
    0
    Views:
    4,391
    Benny Ng
    Oct 3, 2005
  3. Replies:
    7
    Views:
    902
  4. Gelonida N
    Replies:
    2
    Views:
    289
    Gelonida N
    Aug 13, 2012
  5. Thomas Jollans
    Replies:
    0
    Views:
    131
    Thomas Jollans
    Aug 12, 2012
Loading...

Share This Page