Running Migrations Automatically pre_start in Elixir-Distillery-Release on Windows - windows

i need your help!
im trying to run migrations in a distillery release (Elixir-Application) before the application starts automatically (via Boot Hooks -https://hexdocs.pm/distillery/boot-hooks.html#content).
Development and Production platform must be Windows.
The Problem: I cant find any infos about Windows (.bat)-Scripts referencing the problem - I search for a script for the "pre_start.bat"-File - for calling the ERTS Node and finally my Elixir-Code in it.
my distillery-config : rel\config.exs
environment :prod do
...
set pre_start_hook: "rel/hooks/pre_start"
...
end
The required script should call my code of the "Elixir.MyApp.ReleaseTask.migrate"-Function
How can i achieve this??
The following Code is what ive got so far.. but it doesnt work ..
#echo off
echo Running migrations
echo.
echo.
echo.
cd %RELEASE_ROOT_DIR%
#set system_erl="<erl_directory>\erts-9.1\bin\erl.exe"
#set erl=%system_erl%
#set system_root_dir_cmd=%system_erl% -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop
#set rootdir=%system_root%
#set system_erts_vsn_cmd=%system_erl% -noshell -eval "Ver=erlang:system_info(version),io:format(\"~s\", [Ver])" -s init stop
#set erts_vsn=%system_erts_vsn%
#set erts_dir=%rootdir%\erts-%erts_vsn%
#set rel_name="my_api"
#set rel_vsn="1.0"
#set consolidated_dir=%rootdir%\lib\%rel_name%-%rel_vsn%\consolidated
#%erl% -boot_var ERTS_LIB_DIR "%erts_dir%\..\lib" ^
-hidden -noshell -boot start_clean ^
-pa "%consolidated_dir%" ^
-s "Elixir.MyApp.ReleaseTasks" "seed" -s init stop
echo Migrations run successfully
Please correct me when im totally wrong with this.
Any help appreciated! BTW its a phoenix-Application.

I would go with erlang’s native escript instead. To build it:
1. update mix.exs, e.g. add:
escript: [main_module: MyApp, path: "bin/migrator"]
to the array returned by MyApp.Mixfile.project/0 function and add bin directory to the release:
# ⇓⇓⇓
files: ~w|bin lib mix.exs README.md|,
to the array returned by MyApp.Mixfile.package/0
2. create MyApp.main/1 function:
def main(_args) do
MyApp.ReleaseTasks.migrate
end
You are all set. There in release will be escript in bin/migrator (the name you used in step 1.)
Now you should be able to run bin/migrator, since it’s a plain old good executable.
Sidenote: mix compile would build this executable as well, so you might play with it and test it before running with distillery.

Related

How to set variables using terragrunt before_hook

I need to use some gcloud commands in order to create a Redis instance on GCP as terraform does not support some options that I need.
I'm trying this:
terraform {
# Before apply, run script.
before_hook "create_redis_script" {
commands = ["apply"]
execute = ["REDIS_REGION=${local.module_vars.redis_region}", "REDIS_PROJECT=${local.module_vars.redis_project}", "REDIS_VPC=${local.module_vars.redis_vpc}", "REDIS_PREFIX_LENGHT=${local.module_vars.redis_prefix_lenght}", "REDIS_RESERVED_RANGE_NAME=${local.module_vars.redis_reserved_range_name}", "REDIS_RANGE_DESCRIPTION=${local.module_vars.redis_range_description}", "REDIS_NAME=${local.module_vars.redis_name}", "REDIS_SIZE=${local.module_vars.redis_size}", "REDIS_ZONE=${local.module_vars.redis_zone}", "REDIS_ALT_ZONE=${local.module_vars.redis_alt_zone}", "REDIS_VERSION=${local.module_vars.redis_version}", "bash", "../../../scripts/create-redis-instance.sh"]
}
The script is like this:
echo "[+]Creating IP Allocation Automatically using <$REDIS_VPC-network\/$REDIS_PREFIX_LENGHT>"
gcloud compute addresses create $REDIS_RESERVED_RANGE_NAME \
--global \
--purpose=VPC_PEERING \
--prefix-lenght=$REDIS_PREFIX_LENGHT \
--description=$REDIS_RANGE_DESCRIPTION \
--network=$REDIS_VPC
The error I get is:
terragrunt apply
5b35d0bf15d0a0d61b303ed32556b85417e2317f
5b35d0bf15d0a0d61b303ed32556b85417e2317f
5b35d0bf15d0a0d61b303ed32556b85417e2317f
ERRO[0002] Hit multiple errors:
Hit multiple errors:
exec: "REDIS_REGION=us-east1": executable file not found in $PATH
ERRO[0002] Unable to determine underlying exit code, so Terragrunt will exit with error code 1
I encountered the same issue and resigned myself to pass the values as parameters instead of environment variables.
It involves to modify the script and is a far less clearer declaration, but it works :|

How to trigger gitlab ci when a comment like "test please" is written in merge request discussion?

I saw there are several ways to trigger the CI.
Even for merge requests
https://docs.gitlab.com/ee/ci/merge_request_pipelines/
What I want to do is to trigger a gitlab CI pipeline not for all merge request and not for all commits.
Only when someone comments:
'test please' or 'test gitlab' or some special keyword maybe defined by regex?
Is this possible?
That was requested in gitlab-org/gitlab-foss issue 39215, and shipped with 11.0
rspec:
script: ...
only:
variables:
- $CI_COMMIT_MESSAGE =~ /some-regexp/
You also have the following workaround for pipelines (windows cmd shell):
Process the job only if commit message doesn't contain [CI Release]
script:
- git show -s --format=%%B | findstr /C:"[CI Release]" >nul 2>&1 && (exit 0) || (set errorlevel=0)
- cd beUcb
- call mvn -N -Pver resources:resources
- REM ... rest of script ...

Does JanusGraph run on Windows 10

Windows 10, janusgraph-0.2.0-hadoop2.
I have put the winutils.exe in the bin folder.
P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\bin>gremlin-server.bat
Error: Could not find or load main class Files
I had a quick look at the bat script and added some echo statements:
echo "%1"
IF "%1" == "-i" (
GOTO install
) else (
GOTO server
)
:: Start the Gremlin Server
:server
IF "%1" == "" (
SET GREMLIN_SERVER_YAML=%JANUSGRAPH_HOME%\conf\gremlin-server\gremlin-server.yaml
) ELSE (
SET GREMLIN_SERVER_YAML=%1
)
java %JAVA_OPTIONS% %JAVA_ARGS% -cp %CP% org.apache.tinkerpop.gremlin.server.GremlinServer %GREMLIN_SERVER_YAML%
echo %JAVA_OPTIONS%
echo %JAVA_ARGS%
echo %CP%
echo %GREMLIN_SERVER_YAML%
echo "call to GremlinServer"
The output:
P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\bin>gremlin-server.bat
.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\slf4j-log4j12-1.7.12.jar;;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-all-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-berkeleyje-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-bigtable-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-cassandra-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-core-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-cql-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-es-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-hadoop-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-hbase-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-lucene-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-solr-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\*;
""
Error: Could not find or load main class Files
-Xms32m -Xmx512m -Djanusgraph.logdir=P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\log -Dtinkerpop.ext=P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\ext -Dlogback.configurationFile=conf\logback.xml -Dlog4j.configuration=file:/P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\conf\gremlin-server\log4j-server.properties -Dlog4j.debug=true -Dgremlin.log4j.level=WARN -javaagent:P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\jamm-0.3.0.jar -Dgremlin.io.kryoShimService=org.janusgraph.hadoop.serialize.JanusGraphKryoShimService
ECHO is off.
.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\slf4j-log4j12-1.7.12.jar;;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-all-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-berkeleyje-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-bigtable-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-cassandra-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-core-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-cql-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-es-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-hadoop-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-hbase-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-lucene-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\janusgraph-solr-0.2.0.jar;P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\lib\*;
P:\Software\DB\NoSQL\janusgraph-0.2.0-hadoop2\conf\gremlin-server\gremlin-server.yaml
"call to GremlinServer"
This question was also asked on the janusgraph-users Google Group, and I've copied my answers here:
JanusGraph does run on Windows 10. The user experience is not ideal,
and could use some help with people with Windows expertise. I've
opened up issue
950 to track
making the prepackaged distribution more Windows-friendly.
Your problem is probably coming from your CLASSPATH variable, and
I'd think that ".;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;" is messing it up because of the
spaces in the path. Try unsetting the CLASSPATH before running
gremlin-server.bat.
The default Gremlin Server configuration uses
janusgraph-cassandra-es-server.properties because the pre-packaged
distribution bin/janusgraph.sh start will start a single node
Cassandra, a single node Elasticsearch, and the Gremlin Server. If you
want to run with Cassandra, you could go a version directly from the
Apache Cassandra site or a Datastax distribution if you want to go
with an MSI installer. If you're not interested in using Cassandra,
you could change the gremlin-server.yaml to use the
janusgraph-berkeleyje-server.properties which is pretty good for
getting started.

Apache prunsrv: error parsing command line

I'm trying to start a Java program as a Windows Service. Googling I've found a install.bat to install and start my service.
As I found on the Internet, I've renamed prunsrv.exe to IdentificationService.exe.
D:\IdentificationService\bin\IdentificationService.exe //IS//IdentificationService
D:\IdentificationService\bin\IdentificationService.exe //US//IdentificationService --Install=D:\IdentificationService\bin\IdentificationService.exe --Description= Identification Service --Jvm="C:\Program Files (x86)\\Diginet\java\bin\server\jvm.dll" --Classpath=D:\IdentificationService\lib --StartMode=jvm --StartClass=br.com..digis.DiginetIdentificationService --StartMethod=start --StartParams=start --StopMode=jvm --StopClass=br.com..digis.DiginetIdentificationService --StopMethod=stop --StopParams=stop --LogPath=D:\IdentificationService\logs --StdOutput=auto --StdError=auto
net start IdentificationService
My problem is that each time I execute IdentificationService it says "Error parsing command line".
I've tried to enclose all parameters by double quotes. Same results.
I've tried to use the original prunsrv.exe withou renaming it. Same results.
What am I missing?
Try setting the parameters through the environment variables
set SERVICE_NAME=CsvToXmlService
set PR_INSTALL=%cd%\prunsrv.exe
set PR_DESCRIPTION=CsvToXml Service
REM Service log configuration
set PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%cd%
set PR_STDOUTPUT=%cd%\stdout.txt
set PR_STDERROR=%cd%\stderr.txt
set PR_LOGLEVEL=Error
REM Path to java installation
set PR_JVM=C:\Program Files\Java\jre7\bin\server\jvm.dll
set PR_CLASSPATH=%cd%\target\app.jar
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=ru.misterparser.csvtoxmlservice.Main
set PR_STARTMETHOD=start
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=ru.misterparser.csvtoxmlservice.Main
set PR_STOPMETHOD=stop
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=1024
set PR_JVMSS=4000
set PR_JVMOPTIONS=-Duser.language=RU;-Duser.region=ru
REM Install service
prunsrv.exe //IS//%SERVICE_NAME%
sc start %SERVICE_NAME%
rename exe back to prunsrv and run it with exactly same parameters (except first exe ofc)

Steps for installing Orbfit 4.2

I'm trying to install Orbfit4.2 on a using linux mint maya edition. I'm trying to follow the on line help. I have unzipped the tared file, configured with $ ./config -0 gfortran and then $ make. Both appears to be successful. I am now trying to create the DE405 data files in the /orbfit/src/jpleph directory. I have downloaded the header.405 and the ascp*date* ascii files into the directory from JPL. I have run $ make ephemerides and get the following;
cat header.405 ascp1960.405 ascp1980.405 ascp2000.405 ascp2020.405> input.430
asc2eph.x < input.430
/bin/sh: 1: asc2eph.x: not found
make: *** [ephemerides] Error 127
(I have also used input value of 405 instead of 430)
I have also tried just running from with in
the directory
$ ./asc2eph.x which was the previous method before the Makefile was included. All I get with this is 'authors' introductory message and the flashing working box-still running 6 hrs later.
If anybody has any experience or advice with installing Orbfit 4.2 from the start or can help me move on from the above blockage I would appreciate.
Note I am a real novice and would appreciate idiot step by step guide- I'm the idiot.
Eric
The Makefile assumes that the current directory "." is in your path. This is a security risk. You can either edit the Makefile to rename these binaries:
$ diff -u Makefile.orig Makefile
--- Makefile.orig 2014-01-09 07:14:10.000000000 -0800
+++ Makefile 2014-10-21 11:40:00.850236839 -0700
## -10,7 +10,7 ##
make clean
ephemerides: input asc2eph.x
- asc2eph.x < input.430
+ ./asc2eph.x < input.430
mv JPLEPH jpleph
make clean
Or you can add . to your path (but this is insecure!) by doing
$ PATH=.:$PATH

Resources