How to get project name using activator (or sbt)? - bash

I have a Play application (2.3.4) that is getting build with activator like this:
$ activator stage
This will build the project and generate startup script: target/universal/stage/bin/<project name in lowercase>.
Now, I need to get run that startup script from another bash script on my production server.
My question is - how do I get the project name (in lowercase) from activator or sbt (since activator wraps sbt) from bash, so I could run the startup script?
Or, maybe there is a better way to figure out the name of the startup script generated by activator stage.

A project name is concatenation of two keys name and version separated with a dash. Whit a little bit of parsing you can get a value of any key using the SBT show <key> command. I'm not really familiar with writing bash scripts but I hope this hint can give you enough information to solve your problem.

Related

enable certain commands in root level of a project without writing script nor manual setup for local machine

Currenly, if I want to run something like start in a project, let say /myproject I have to make a new bash file and name it like start in order to have some sort of command like ./start to work properly.
But I want to do is somehow I can add some sort of config file into the root folder to run all different kinds of command without ./ needed and simply start or anything else as I want to make, without having to create whole bunch of bash files.
Is there a way to setup it so if someone just pull a git repo down can just have it?
Assume that the git repo also contains package.json or maybe gradle.
However, I dont want to use npm run xxx or gradle xxx its just too much typing...
Sorry if I am asking too much for a setup lol

spring-boot launch-script: how to avoid pid_folder identity-subdirectory?

We are using spring-boot with the embedded launcher-script in service mode, to have daemonized/init.d behavior.
We however do not have an /etc/init.d symlink to the spring-boot jar as that would require using sudo. we avoid sudo to pass a profile-environmental like -Dspring.profiles.active=$APP_PROFILE in the JAVA_OPTS
(this won't work when started via sudo but defined in /home/appuser/.bashrc (?) )
We have this directory-layout with some indirections. basically app.jar => current/app.jar => build-xx/app.jar
appuser#host:~/apps/services$ ls
app.jar -> /home/appuser/apps/services/current/services-1.0-SNAPSHOT.jar
current -> /home/appuser/apps/services/services-1298
services-1298
When starting the application with app.jar start the launch-script generates an additional pid-subdirectory in the pid-folder based on the "identity" of the program. For us this can look like this:
/home/appuser/apps/services/run/services-1.0-SNAPSHOT_homeappuserappsservicesservices-1298/services.pid
Unlike when used with an symlinked /etc/init.d which gets special treatment and the pid-subdir services-1.0-SNAPSHOT_homeappuserappsservicesservices-1298 is omitted/stays stable.
This dynamic pid-subdir makes it very hard for us to check the daemon's status or start/stop during deployment because you have to always get the sequence right and nobody is stopping you from starting a process twice (the old instance and now a new instance with a new identity-subdir).
So, does anyone know why this pid-subdir-identity stuff must exist and what would be our best way to deal with it?
Do we have a bad setup?
Any advice appreciated.
You can control the identity by using the APP_NAME environment variable.
I'd recommend configuring your service's environment variables using a .conf file next to the jar file. For example, if your app is called app.jar, you conf file should be named app.conf and be placed in the same directory as the jar. You can then configure APP_NAME and JAVA_OPTS etc for your application. This should allow you to use init.d if you so wish.

Error: Could not find or load main class org.apache.jackrabbit.vault.cli.VaultFsApp

We use VLT and GIT for our AEM site development.
I prefer the branch notifications and color coding etc. of GIT Bash,
to the standard output.
I use both from within ConEmu, and I have added Clink,
and that is somewhat better, but not as nice as GIT Bash.
Using the regular console I'm able to access VLT,
but when using the GIT Bash console, I get the following error.
"Error: Could not find or load main class org.apache.jackrabbit.vault.cli.VaultFsApp"
So it seems that there is a path that is not being found,
but running env|grep PATH shows the correct info.
Any help would be appreciated.
The shell's "PATH" isn't the problem.
You need to fix the Java "CLASSPATH".
You haven't specified your OS (Windows? Linux? Other?)
And I'm not sure exactly which program in the mix is using "org.apache.jackgrabbit.vault.cli". It certainly isn't Git BASH - it sounds like VLT is the guy who needs you to add Apache Jackrabbit to its Java CLASSPATH.
I fixed this in Windows 10 by running the command in cmd, rather than in git bash

TeamCity: How to show parameters in the history

I have 3 servers for PROD, with the same deployment build configuration, I choose which server to deploy depending on a build parameter.
The issue is that reviewing the history you can't check which environment are you deploying.
I wonder if it's possible one of this solutions:
- Show parameters in the history of a build
- Autotag a build with parameters
I hope I had explained well enough.
Thanks in advance
You can accomplish this with a Command Line build step that echoes the relevant parameters to the build log. For a Windows-based agent, you could do something like:
Run: Executable with parameters
Command Executable: echo
Command Parameters: Deployed to server %your.server.host%
This would simply add a line to the build log that reads, Deployed to server FOO
Autotagging would be pretty cool, but I don't know of a way to do that.

What's the simplest way to run a cron job on a standalone Ruby gem?

I have a gem that packages one .rb file containing my class and associated methods as well as a corresponding .bin file.
Locally, I can run everything just fine like so:
command_to_bin input_file output_file
I don't want to run this manually every day so I'm considering using cron on a server, but I'm a little unsure how to proceed.
Do I throw everything into a directory (.gem file, input file, output file) and just point the above cron command at the directory?
I've looked at this and sort of understand what's going on. I guess what confuses me the most is that when I look at all the web hosting providers, they mention domains and applications, but I just want to know how to have the standalone script run by itself without it being built into a web application or associated with a domain.
Check out the whenever gem. It's a wonderful gem to abstract all the nastiness of cron. Just include the command as you have written above and it should be fine.
You don't need to install Rails. After you wheneverize . the directory and set the schedule in your schedule.rb file, you need to run whenever --update-crontab to set everything to the system. Otherwise your cron jobs never get converted to Unix Cron

Resources