I have 2 flask restful API's .
On my localhost, I open up a terminal and run uwsgi --ini /path-to-ini-file1. For 2nd API, I open up yet agan a new terminal and run uwsgi --ini /path-to-ini-file2.
In VPS, I have only a single ssh window.
How do I run those 2 on terminals in vps using ssh. Should I create a bin/bash script to achieve that?
Any suggestion would be appreciated, thank you.
Asked
Active
Viewed 845 times
0
ksalf
- 3
- 1
-
Can't you just make a second ssh connection from an other terminal-window ? – Soren A Apr 12 '19 at 13:06
-
@SorenA: Thanks for replying, Sir. So is it like I open up as many ssh windows I want, run commands, and then close them up, and my server would keep running them, until I restart it? Upon closing the ssh on my home pc, would the command be still running on the server? Fairly new to vps, so pardon me for silly questions. – ksalf Apr 12 '19 at 13:13
-
2If you run the command in foreground (thats what you normally do, the command will terminate when you closethe ssh connection - but that's also what happens when you close the terminal running locally. Maybe you should look at the `screen` tool. That allows you to have many sessions running at once, and they will survive disconnection / connection to your remote server / VPS. You might have to install screen on your VPS. – Soren A Apr 12 '19 at 13:23
-
@SorenA: Thanks a lot, Sir. Your comment cleared all my doubts, thank you very much. – ksalf Apr 12 '19 at 13:32
2 Answers
0
To run commands in background and do not have them attach to the terminal you need to use something like:
nohup uwsgi --ini /path-to-ini-file1 >out1.log 2>err1.log&
nohup uwsgi --ini /path-to-ini-file2 >out2.log 2>err2.log&
And you can run as many as need servers (limited by RAM and processor power).
And after you logour from the server you will have them run
Romeo Ninov
- 699
- 6
- 12
-
1.Thanks a lot for your answer, Sir. Trying right now, what you have just suggested – ksalf Apr 12 '19 at 13:34
0
If this is supposed to run on an unattended machine, make these a service, so that they are automatically taken care off (started,restarted, logged...). It is not difficult to make a systemd service.
xenoid
- 5,376
- 2
- 16
- 34
-
Thanks a lot for telling something new to me , Sir. Visited the link you posted, very knowledgeable. – ksalf Apr 12 '19 at 15:18