Corda standalone shell - execute command without entering into shell - corda

The --help of Cords Standalone Shell says the following:
corda-shell [-hvV] [--logging-level=<loggingLevel>] [--password=<password>]
[--sshd-hostkey-directory=<sshdHostKeyDirectory>]
[--sshd-port=<sshdPort>] [--truststore-file=<trustStoreFile>]
[--truststore-password=<trustStorePassword>]
[--truststore-type=<trustStoreType>] [--user=<user>] [-a=<host>]
[-c=<cordappDirectory>] [-f=<configFile>] [-o=<commandsDirectory>]
[-p=<port>] [COMMAND]
Now I was thinking that after specifying the appropriate parameters I can specify the [COMMAND] which I want to be executed on the node (e.g. run gracefulShutdown) but I cannot find a way to do that with standalone shell. Is there a way to do that or may be I am on wrong direction?
P.S. I need to drain and shut down the node before deploying the new cordapp in my CI/CD flow, thats why I need run gracefulShutdown.
When I try to run a command using this technique I get the following error:
Unmatched argument: help
Did you mean: install-shell-extensions?

Method-1 -- Submit/STDIN the commands via pipe.
echo -e "run nodeInfo\nexit"|java -jar corda-tools-shell-cli-4.8.7.jar \
--truststore-file /$PWD/certificates/export/rpcssltruststore.jks \
--truststore-password=apple -p=10006 -a localhost \
--user user1 --password=test
Method-2 -- Text the commands in a file and provide it as STDIN
]$ cat /tmp/commands
run nodeInfo
exit
]$ java -jar ~/bin/es/corda-tools-shell-cli-4.8.7.jar --truststore-file /$PWD/certificates/export/rpcssltruststore.jks --truststore-password=rpctruststorepassword -p=10006 -a localhost --user user1 --password=test < /tmp/commands
______ __
/ ____/ _________/ /___ _
/ / __ / ___/ __ / __ `/
/ /___ /_/ / / / /_/ / /_/ /
\____/ /_/ \__,_/\__,_/
--- Corda Enterprise Edition 4.8.7 (8baf4b1) ---
Standalone Shell connected to localhost:10006
Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to exit the shell.
Tue Jul 26 16:01:16 SGT 2022>>> run nodeInfo
addresses:
- "localhost:10005"
legalIdentitiesAndCerts:
- "O=PartyA, L=London, C=GB"
platformVersion: 10
serial: 1658810279418
Tue Jul 26 16:01:16 SGT 2022>>> exit
Have a good day!
]$
Important is to ensure and keep exit at the end.

You need to first enter into the shell to be able to issue commands to the node. The [COMMAND] parameter is probably a little misleading, The only command it has is 'install-shell-extension' which just adds an alias so that the jar can be run using a suitable name like 'corda-shell'.

Related

AWS Sagemaker pipeline definition error while running from aws-cli

Im trying to integrate Sagemaker pipeline with Jenkins. Im using aws-cli ( version - 2.1.24 ).
Since this version doesnt support --pipeline-definition-s3-location, Im trying to do something like below -
aws s3 cp s3://some_bucket/folder1/pipeine_definition.json - | \ jq -c . | \ tee /dev/stderr | \ xargs -0 -I{} aws sagemaker update-pipeline --pipeline-name "pipelinename" --role-arn "arn:aws:iam::<account_id>:role/sagemaker-role" --pipeline-definition '{}'
And I found this error -
An error occurred (ValidationException) when calling the UpdatePipeline operation: Pipeline definition: At least 1 step must be provided
When I recheck the definition.json, Im able to see the steps defined inside json.
Can someone help me?
I tried adding the quotes for --pipeline-definition, which isnt working.
Since jenkins has aws-cli 2.1.24 version, I want to someone copy the contents of json file in s3 and pass it to --pipeline-definition argument using aws sagemaker --update-pipeline command.

solr / tomcat7 doesn't come back up after a crash

I keep getting issues with Solr crashing on my server. Its hardly a busy site, so I'm baffled as to why it keeps doing it.
Anyway, as an intermediary - I'm written a shell script that runs on a cron as root:
#!/bin/bash
declare -a arr=(tomcat7 nginx mysql);
for i in "${arr[#]}"
do
echo "Checking $i"
if (( $(ps -ef | grep -v grep | grep $i | wc -l) > 0 ))
then
echo "$i is running!!!"
else
echo "service $i start\n"
service $i start
fi
done
# re-run, but this time do a restart if its still not going!
for i in "${arr[#]}"
do
echo "Checking $i"
if (( $(ps -ef | grep -v grep | grep $i | wc -l) > 0 ))
then
echo "$i is running!!!"
else
service $i restart
fi
done
..then this cron (as root)
*/5 * * * * bash /root/script-checks.sh
The cron itself seems to run just fine:
Checking tomcat7
service tomcat7 start\n
Checking nginx
nginx is running!!!
Checking mysql
mysql is running!!!
Checking tomcat7
Checking nginx
nginx is running!!!
Checking mysql
mysql is running!!!
...and Tomcats status seems ok:
root#domain:~# service tomcat7 status
รข tomcat7.service - LSB: Start Tomcat.
Loaded: loaded (/etc/init.d/tomcat7)
Active: active (exited) since Mon 2016-03-21 06:33:28 GMT; 4 days ago
Process: 2695 ExecStart=/etc/init.d/tomcat7 start (code=exited, status=0/SUCCESS)
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
...yet my script, can't connect to Solr:
Could not parse JSON response: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "Can't connect to loc...") at /srv/www/domain.net/www/cgi-bin/admin/WebService/Solr/Response.pm line 42. Can't connect to localhost:8080 Connection refused at /usr/share/perl5/LWP/Protocol/http.pm line 49.
If I manually run a "restart":
service tomcat7 restart
...it then starts working again. Its almost like the 2nd part in my shell script isn't working.
Any suggestions?
My Solr versions are as follows:
Solr Specification Version: 3.6.2.2014.10.31.18.33.47
Solr Implementation Version: 3.6.2 debian - pbuilder - 2014-10-31 18:33:47
Lucene Specification Version: 3.6.2
UPDATE: I've read that sometimes updating the maxThreads can help with crashes, so I've changed it to 10,000:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="10000" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
I guess time will tell, to see if this fixes the issue.
Ok, well I never got to the bottom of why it wouldn't restart... but I have worked out why it was crashing. Before, we had it on 2048mb RAM Linode server, but when we moved over to Apache2, I setup a 1024Mb server, and was going to upgrade it to 2048mb one we had it all working. However, we put it live - but I forgot to update it to the 2048mb server, so Nginx/Apache2/Tomcat/MySQL etc, were all trying to run on a pretty slow server.
We found that Solr was dying with an OOM (out of memory) error, which is what gave us the clue.
Hopefully this helps someone else, who may come across this.

Ansible command to check the java version in different servers

I am writing a Test case using ansible.There are totally 9 servers in which I need to check whether the installed java version is 1.7.0 or not?
If it is less than 1.7.0 then test case should fail.
Can anyone help me to write this Test case as I am very new to ansible.
Thanks in advance
Ansible has a version_compare filter since 1.6. But since Ansible doesn't know about your Java version you first need to fetch it in a separate task and register the output, so you can compare it.
- name: Fetch Java version
shell: java -version 2>&1 | grep version | awk '{print $3}' | sed 's/"//g'
register: java_version
- assert:
that:
- java_version.stdout | version_compare('1.7', '>=')
On a sidenote, if your main use case for Ansible is to validate the server state you might want to have a look at using an infrastructure test tool instead: serverspec, goss, inspec, testinfra.
Altough in your question you havn't specified what have you tried, but still
You can run a commands like this
ansible your_host -m command -a 'java -version'
If you need to parse the output of java -version there is a very good script from Glenn Jackman here adapt it to your needs and use it.
If you are still looking for help, be more specific and show what you tried to do.
Since 2.0 you can make this
- name: Check if java is installed
command: java -version
become_user: '{{ global_vars.user_session }}' // your user session
register: java_result
ignore_errors: True
- debug:
msg: "Failed - Java is not installed"
when: java_result is failed
- debug:
msg: "Success - Java is installed"
when: java_result is success

In a local installation of edX, where are the log files and the console?

I'm getting errors from the Studio page, and I want to see what the errors are on the server side.
I also see mention here https://github.com/edx/configuration/wiki/edX-Developer-Stack#signing-up-a-new-user-activation-message-problems that there is a console. When logged into the edX VM, how do I monitor this console?
I'm getting errors from the Studio page, and I want to see what the errors are on the server side
Try looking in /edx/var/log
When logged into the edX VM, how do I monitor this console?
Those are instructions for devstack, if you are using devstack you would be running runserver in the console which is where those messages would appear.
I'm getting errors from the Studio page, and I want to see what the errors are on the server side.
For Studio errors look in /edx/var/log/cms/edx.log inside your virtual box VM.
When logged into the edX VM, how do I monitor this console?
To run and monitor the console, perform the following steps starting from your installed vagrant directory (the one with the Vagrantfile) on your host:
First, ssh into the VM:
vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
New release '14.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*******************************************************************
* ___ _ __ __ *
* / _ \ _ __ ___ _ _ ___ __| |\ \/ / *
* | |_| | '_ \ -_) ' \ / -_) _` | > < *
* \___/| .__/___|_|_| \___\__,_|/_/\_\ *
* |_| *
* *
* Instructions and troubleshooting: *
* https://github.com/edx/configuration/wiki/edX-Developer-Stack *
*******************************************************************
Last login: Tue May 12 22:21:14 2015 from 10.0.2.2
Then become the edxapp user:
vagrant#precise64:~$ sudo su edxapp -s /bin/bash
edxapp#precise64:~/edx-platform$ cd ~
edxapp#precise64:~$ source edxapp_env
Start the Studio application (--fast is optional):
edxapp#precise64:~$ cd edx-platform/
edxapp#precise64:~/edx-platform$ paver devstack --fast studio
---> pavelib.servers.devstack
---> pavelib.prereqs.install_prereqs
Enter CTL-C to end
Validating models...
0 errors found
Django version 1.4.18, using settings 'cms.envs.devstack'
Development server is running at http://0.0.0.0:8001/
Quit the server with CONTROL-C.
In this example, the first line of the console output is:
---> pavelib.servers.devstack

How can I get the names of the applications that are installed on an application server?

I have an SSH access to my application. Is there any UNIX code that I can use to get the name of the applications installed?
Thanks!
Actually I don't understand when you talk about "my applicattion" or "applications installed" what are you exactly refering.
1) If you want to know what applications are deployed, for example in the application server of your instance, for example Tomcat 7 you can take a look here: List Currently Deployed Applications
2) Or maybe you are looking for SO installed applications.
Depeending on what OS is running may be different. For example for Red Hat Enterprise / Fedora Linux / Suse Linux / Cent OS:
Under Red Hat/Fedora Linux:
$ rpm -qa | grep {package-name}
For example find out package mutt installed or not:
$ rpm -qa | grep mutt
Output:
mutt-1.4.1-10
If you don't get any output ( package name along with version), it means package is not installed at all. You can display list all installed packages with the following command:
$ rpm -qa
$ rpm -qa | less
3) Another useful command is ps command. You can check what is running with the ps command.
Type the following ps command to display all running process:
ps aux | less
Where,
A: select all processes
a: select all processes on a terminal, including those of other users
x: select processes without controlling ttys
Task: see every process on the system
ps -A
ps -e

Resources