Deploying to same server with different ruby versions - ruby

I wrote an import script that has grown into a full import environment.
Basicaly I can run 3 different imports by executing thor tasks.
I set up a capistrano3 deploy script to transfer all of this a server. After deployment capistrano/whenever will generate a crontab file to execute the import tasks at various times.
Now I ran into the problem, that I need a different ruby version for one of the imports (MRI instead of JRuby).
I am currently using rbenv (I don't want to switch to rvm). I thought that the easiest way would be to deploy to 2 directories (e.g. /srv/ruby/app/mri and /srv/ruby/app/jruby) and defining the ruby versions as roles (i also need staging and production environment).
I already took a look at capistrano/multiconfig but I cannot wrap my head around it.
Someone did something similar or hash experience on how to do that?

Related

How to package & share Selenium scripts with non-technical team?

I have a few python/selenium scripts that automate tedious work in browser-based apps (e.g., data entry from a CSV file).
I would like to share the scripts with my team members who are tech-savvy but don't know how to code.
How can I package up the scripts with all the dependencies so that "it just works" when downloaded?
Dependencies are:
Install python and add to PATH
Install selenium, pandas, autopylogger
Install selenium chromedrivers
...and a few other simple changes to variables/file paths in the scripts
My first instinct was to dockerize the environment, but because the automation need to use the user's Chrome profiles and docker runs on WSL I imagine that would cause issues. And setting up WSL + Docker Desktop isn't exactly simplifying things.
Jenkins, Replit, Maven, and other hosted options would have a similar issue using the user's Chrome profile (I think?)
I'm currently thinking I'll write a .BAT script that sets up the environment, but I haven't done that before and am hoping there's an easier way.
I would say,
1)Create a Jenkin job.
In Selenium, you can pass chrome user profile as an argument. They can save their chrome user profile from the chrome browser and pass it as an argument through jenkins.
Below is the sample code of how to pass custom chrome profiles:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("user-data-
dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe',
chrome_options=options)
driver.get("https://www.google.co.in")
Let them store their profile in a accessible path, where it can be passed as an argument to Jenkins

How can I test my Ruby CLI app while still in development?

Morning guys,
I am writing a small Ruby CLI app for myself, and I have run into a small issue that I hope you guys can help with. Apologies if this is a stupid question, I am very new to Ruby.
I am using https://github.com/davetron5000/gli as a foundation to build my my app since they make it easy to have all my commands and whatnot.
Question is, while I develop the app, I can run it using bundle exec bin/konstruct, but that only works from the folder where the code lies.
I want to run the app from a test folder so I can see whether the code I'm adding is doing what it should (make files, remove files, see if directory is empty, etc).
When I played around with NodeJS, I could link the app, and it would work anywhere. Is there something like that for Ruby apps that are still in development?
Two simple way:
1. Make bin/konstruct executable. So you can run it without bundle exec. Then link it in any directory in your $PATH with ln -s. (For Unix based systems)
2. Create a alias in your shell. something like this:
alias konstruct="bundle exec /FULL/PATH/TO/bin/konstruct"
(Also for Unix based systems)

How to install jenkins under current user (not 'jenkins') on MAC OS X

I have configured MAC OS X environment (SDKs, licenses, etc) under current user for build server and would like to reuse all the settings by a build agent. Jenkins was chosen as a good option but for some reason during installation it created a new user jenkins and launch the app under it, causing the environment setup to be not accessible (no SDKs, no licenses are found anymore).
Is it possible to install jenkins under current user?
Probably it could be installed under jenkins but then launched under current user?
Any other good options for me to consider are appreciated.
Try this: http://www.sailmaker.co.uk/blog/2013/04/02/advanced-jenkins-for-ios-and-mac/#Installing-Jenkins-itself
I’m also going to recommend installing Jenkins via Homebrew, to avoid
some nonsense in Jenkins’ own installer whereby it puts itself in
/Users/Shared/. You really don’t want that.
If you're free to reinstall however you'd like, I'd recommend re-installing as the user you want to use, using whatever type of install you prefer, and then simply copy over the old Jenkins data directory to the new installation's location, and then changing the permissions in that directory.
That is to say, the directory containing the config, plugin and job information (it may be something like /usr/lib/jenkins, but could vary).
Then, chown -R the data directory using the user:group info you want to use so Jenkins has access to the files.
I have used this type of method in the past to transfer all the data from one install to another totally separate install on the same box, and it has worked well (one could use this method to transfer the data to an install on another box, as well).
Note: I would highly recommend making a full backup of the data directory before doing this, in case anything goes awry.

Maintaining multiple standalone ruby scripts on same machine

I have one machine which runs multiple standalone ruby scripts. Every time I have to upgrade some gem for one of the scripts, I have to look for its impact on other scripts as well. Do you think it will be a good practice to create one gemfile each for a ruby script or can someone recommend me a better way to maintain such system? I also sometimes want to use different versions of the same gem in different scripts.
How about using RVM or RbEnv?
In this case, you will need to have each file in a separate folder with rvm/rbenv config.
I create independent gemset for each project to be sure that all be ok with gems and it's versions.
RVM gives all the tools to manage gemsets.
So you will need to create a separate folder for each script with its own .ruby-gemset in it.

TexLive on Heroku etc. - What are my options ?

I am trying to build a Rails application that would internally invoke LaTeX
to stitch together TeX files to generate documents on the fly. Not necessarily PDF.
Just TeX -> DVI -> PS would do it for me.
My best guess is that I would need to host 2 separate code-bases, one for
Rails code ( the standard $RAILS_ROOT ) and (possibly) a separate directory structure
for hosting the TeX files ( which is also code in a way ). And as I see it,
the Rails app would make system calls to LaTeX (latex <options> <files>)
on the TeX files to do what I want it to do
I was wondering, therefore, if you guys could help me decide what the
best hosting option could be for the above setup ( unless, you think that
the setup itself should be different )
I know that something like Heroku would allow me to host the Rails bit easily.
But as far as I can tell, their servers do not have full TexLive installation which I need.
I have asked them if they could install TexLive on their servers. But assuming
they don't entertain one off requests, what are my options ?
Do I then need to recreate my local setup from scratch on something like Amazon's EC2 ?
Any pointers on available options and the tasks they would entail would be most
helpful.
Thanks
Abhinav
I think you should be able to make it work on Heroku but you may need to write a custom buildpack which includes/installs the latex binaries:
https://devcenter.heroku.com/articles/buildpacks
There is already a buildpack for TeX and it works for me perfectly:
https://github.com/holiture/heroku-buildpack-tex

Resources