rpc_rr_example {pbdRPC} | R Documentation |
Example functions of RPC related to remote R server
check_rr(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, cmd = .pbd_env$RPC.RR$check) kill_rr(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, cmd = .pbd_env$RPC.RR$kill) start_rr(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, preload = .pbd_env$RPC.RR$preload, cmd = .pbd_env$RPC.RR$start)
exec.type |
either "ssh" or "plink" in character. Windows will force to use "plink". |
args |
further arguments to "ssh" or "plink" for connecting to the server in addition to port, user id, and host name. |
pport |
ssh port opened on the server. |
user |
user id for logging to the server. |
hostname |
the server ip or host name. |
priv.key, priv.key.ppk |
location of the private key for user authentication, the file will be
checked first then |
cmd |
the main command to be executed on the server. |
preload |
further commands preloaded before the main |
Using either ssh
or plink
to launch a remote R server.
NO further input from stdin
is expected.
Outputs or errors may not be captured by R.
start_rr()
starts a remote R server on a remote server.
Typical commands to launch a remoter R server is given in the example.
The linux/unix commands are as the following:
1)nohup
is for the non-stop call after disconnection.
2)Rscript -e 'remoter::server()'
is for R to start the
remote R server in batch.
3)> .rrlog
is to direct the stdout
to a file
.rrlog
4)2>&1
is to turn stderr
to stdout
which
is the file .rrlog
.
5)< /dev/null
is to get stdin
from
/dev/null
which is nothing happen.
6)&
is to put the batch command for the remoter R server
in background.
check_rr()
checks if there is a remote R server on a remote
server. Lunix/unix commands ps
and grep
are used.
kill_rr()
kills remote R servers if found.
Lunix/unix commands ps
, grep
, awk
, and kill
are used.
Mainly the message received at the command line will be printed, but may not be captured by R.
## Not run: library(pbdRPC, quietly = TRUE) rpcopt_set(user = "snoweye", hostname = "192.168.56.101") check_rr() # pid 2857 (may differ) kill_rr() # all remoter pids are killed check_rr() # make sure no remoter servers are running ### use "; " to bypass multiple commands preload <- "source ~/work-my/00_set_devel_R; " ### start a new remoter server start_rr(preload = preload) check_rr() kill_rr() ### Example: for module load on supercomputers preload <- "module load r; " # e.g. via module load r start_rr(preload = preload) check_rr() kill_rr() ## End(Not run)