Erlang home directory - erlang

Hi I have a command which starts an Erlang node (using run_erl program) and then I connect to it using to_erl program.
After connecting to the node I issue the following command to get the home dir.
init:get_argument(home).
And it returns "/" as the home directory, which I know it is definitely wrong.
What is the reason for this?

I do not know how you setup is so it is hard to analyse but the init:get_argument(home) call will return the value of the environment variable HOME (on any form of unix and it can be inspected by calling echo $HOME).

Related

Fail Connect to Running Phoenix Applications with IEx Remote Shell at Docker

Im deploy phx app using docker, running --remsh command from within the same container.
But it return could not contact remote node.
Anybody know the solution ?
Here is the snapshot
You seem to start the application as :nonode#nohost. To connect to it, you should have it started with either a short or fully qualified name.
mix release.init creates rel folder with two template files in it. Check env.sh.eex and make sure you start a release with a short name given. This should work:
export RELEASE_DISTRIBUTION=sname
export RELEASE_NODE=<%= #release.name %>
Sidenote: please post everything as plain text, not as images.
There is a problem in your command, please use --cookie instead of -cookie

Erlang: print loaded sys.config in OTP application

How do I show the absolute path that my Erlang OTP application is loading sys.config from? I.e., if get_all_env (http://erlang.org/doc/apps/kernel/application.html#get_all_env-0) shows unexpected results, how do I see what file is being loaded to debug?
I did this once, so I know it is possible, but sadly I cannot find that code =(
You can use init:get_plain_arguments/0 to get the full list of VM arguments:
(node#localhost)13> init:get_plain_arguments().
["/usr/local/bin/rebar3","shell","--apps","some_app",
"--config","priv/sys.config","--sname","node1#localhost"]
That certainly works if you have started the node manually on CLI. For reference, the output above corresponds to my start script using rebar3:
rebar3 shell --apps some_app --config priv/sys.config --sname node1#localhost

How to stop/start Neo4j server via .bat script in windows

When running the neo4j server in Linux, we have several commands - start, stop, restart, etc - to control it via the command line.
In windows, the manual simply says:
Usage - Windows
Neo4j.bat
Double-clicking on the Neo4j.bat script will start the server in a console. To quit, just press control-C in the console window.
But how do I stop it if I've started it by executing neo4j.bat from a .bat file of my own, and thus don't have a console window?
For context: I'm working on an unmanaged extension, so I need to rebuild my jar, move it into the plugins directory and restart the server each time I make a change. It'd be a pain in the ass to do this manually, so (when when I was working in Linux) I had Intellij rebuild the artifact and execute a .sh script that moved the resultant jar into /plugins and restarted neo4j.
'/path/to/neo4j/bin/neo4j' stop
rm /path/to/neo4j/plugins/api.jar
mv /project/path/artifacts/graphapi.jar /path/to/neo4j/plugins/api.jar
'/path/to/neo4j' start
How do I do the same in windows using a .bat file?
I've tried this:
del "C:/path/to/neo/plugins/api.jar
move "C:/project/path/artifacts/api.jar" "C:/path/to/neo/plugins/api.jar"
C:/neo/bin/Neo4j.bat
hoping that simply calling Neo4j.bat again would stop the current process and start another, but apparently that's not the case.
If you're on Windows you can stop Neo4j server by executing: neo4j.bat stop
Let me show it in details for those who might be new to the command line:
We need to know where Neo4j is located. If you remember where did you extract it - good, you can skip this step. For others: open Task Manager and look for Commons Daemon Service Runner here how it looks like right mouse click, open Properties and look for its Location path. Find this path in your file manager. We are looking for bin folder with neo4j.bat file.
Open command line and write cd and then paste your path, hit enter. You should jump to that folder with neo4j.bat file.
Stop the server: Type neo4j.bat stop and execute. It will ask for your permission .
after that, you can double check and type 'neo4j.bat status` t be sure it's stopped.
P.S. After Windows reboot neo4j server will be automatically restarted. If you don't want this (it consumes up to 500Mb of memory, at least in my DB ~64k records) you should uninstall the service.
Execute neo4j.bat uninstall-service in that directory.
Cheers!

Jenkins fails to execute while running as winservice

I am able to run my script successfully from jenkins when jenking is opened using war file.
If set the jenkinks as winservice my script is failing in middle.
I am trying to run a start.bat file from jenkinks, this bat file calls a java class. again this java class uses bat file to run a plink command.
Execution stops at this stepsif jenkinks is running as winservice and also I can't view the output as it is running in background.
Is there any way to make jenkinks behave normal while running as winservice
Thanks
Try this:
1. Go to services (hit windows key, type "services", select "Services" from the list of matches).
2. Find the Jenkins service and open it's properties
3. Switch to Log On tab
4. Change the service to run as you, instead of local system user.
5. Restart service.
Alternative is to fix local system user account (probably environment variables) so it works as local system user.

How to see Erlang application Console which is running in backgroud?

I am using rebar for release build of erlang application, when I use start option to start the application it is running fine in background and It returns me the command prompt. I don't want to see all the background output, so I did not run using console option. But If I need any time what is going in background, to check the console due to any error, how do I get that running application's console?
I guess that you have made a release using Rebar and that you have started the node with the generated start script.
So the best way would be to use the start option 'attach':
./bin/mynode attach
It will connect to the shell through pipes so you will be in the actual node that are running so be careful with using Ctrl-c. (add the option "+Bi" to your vm.args file to restrict that..)
You can connect a remote shell to the node, provided it's been set up for distribution. Use the following command:
erl -sname rem -remsh node#host -setcookie the_cookie -hidden
Ctrl-G to enter JCL mode, then 'j' to list, then 'c' followed by a number to connect to the chosen job. See the eshell docs, specifically the JCL section.
Oh, or if by 'command prompt' you mean an OS shell rather than an Erlang shell, IIRC you need to start an Erlang node that is appropriately -name'd or -sname'd (whichever the node you want to connect to uses), then connect to that node ('r' in JCL mode), then connect to the job.

Resources