Run Servers in One Command

Start the server

I assume that you have written a configuration file and the path to it is “~/xpd_server.ini”. If you haven’t, here is an example of the configuration file.

[METADATA]
composition_str = composition_str
sample_name = sample_name
user_config = user_config
pyfai_calib_kwargs = pyfai_calib_kwargs

[ANALYSIS]
detectors = pe1c
image_fields = pe1c_image
image_dtype = uint32
fill = True
auto_mask = True
alpha = 2.0
edge = 20
lower_thresh = 0.0
npt = 3000
correctsolidangle = False
polarization_factor = 0.99
method = bbox,csr,cython
normalization_factor = 1.0
pdfgetx = True
rpoly = 1.2
qmaxinst = 24.0
qmax = 22.0
qmin = 0.0
rmin = 0.0
rmax = 30.0
rstep = 0.01
composition = Ni
exports = yaml,poni,tiff,mask,csv,chi,chi_2theta,sq,fq,gr
tiff_base = /nsls2/data/pdf/legacy/processed/xpdacq_data/user_data/tiff_base
directory = {sample_name}
file_prefix = {sample_name}
save_plots = False
is_test = False

[VISUALIZATION]
visualizers = masked_image,chi_2theta,chi,fq,gr,gr_max

[PROXY]
inbound_address = xf28id1-ca1:5577
outbound_address = xf28id1-ca1:5578
raw_data_prefix = raw
analyzed_data_prefix = an

You will find more details about the parameters in the other chapters of the servers. Here, I only show how to use it start a server.

In terminal, run the command:

run_server ~/xpd_server.ini

The server will start in terminal.

If you would like to terminate the server, press CTRL + C.

(Optional) Run the server in a detached background process

Similar to what you have done with the proxy, you can also run the server in background and detach it from the terminal so that you don’t need to start the server every time. To do this, in terminal, run command:

nohup run_server ~/xpd_server.ini &

If you have put the “xpd_server.ini” in default folder, run this instead:

nohup run_server xpd_server &

You will find the message from the server in file “nohup.out”.

If you would like to terminate the background process, in terminal, run command:

kill <job ID>

The <job ID> is a number that shows up after you run the command nohup run_server xpd &.

You can also use other command like tmux to make a terminal session detached.