Tricks about nc and supervisor

188 阅读1分钟

Today i have learnt two effienct tools, one is for transfering files between two machines, and another is for monitoring and restarting monitored process when down. nc tool comes first, if you want to transfer files between machines, you can do this below:

1. on the receiving end, 
nc -l 1234 > xxx
2. on the send end, where ip is the receiving end ip address,
nc ip 1234 < xxx

You may come to an error as below,

Ncat: socket: Address family not supported by protocol QUITTING.

Then you should specify l4 to use the ipv4 address family,

nc -l4 1234 > xxx 

Then comes the supervisor tool, it can be used to monitor and restart the processes, in /etc/supervisor.d/xxx.conf, you can set the processes that need to be monitored and the processes will be restarted automatically by supervisor when down. There are some usually used commands:

supervisorctl status
supervisorctl stop xxx 
supervisorctl start xxx 

When the xxx.conf is changed or yyy.conf is added to conf dir, you need to perform command supervisorctl update to update the conf file.