Can to keep web app running even when the console closed? - web

I run "gradle tomcatRunWar" to start a web app running. When the console is closed, it will stop. How to keep the web app running even when console closed? I prefer not to use screen, and so on...

If you prefer not to use a multiplexer like screen or tmux, you can use nohup as a simple one-liner.
The following command will run gradle in the background:
nohup gradle tomcatRunWar &
Here is some more info on the nohup command.

Related

Chromedriver closes after running nohup on google cloud

I have got a simple script which uses selenium and chromedriver. I have installed the chrome. When I run the script using the command nohup python3.7 -u main.py & tail -f nohup.out everything works; script works as it should. When I close the window of the google cloud ssh the scripts stop working. When I reopen the ssh and call tail -f nohup.out I receive such an error
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: headless chrome=75.0.3770.142)
I was using the chrome version 87 and read that downgrading it should help, so I downgrade it to 75.
It is run on ubuntu, chrome and chromedriver version are 75. Is there such a command that would make chromedriver not close after closing the ssh window?
You can start processes in background in Linux. They will continue running even when you log off (which closing SSH window essentially is).
There are several ways:
Using bg & disown - as described here
Using screen as described here
You can go through entire thread to get more ideas. I'd recommend using bg & disown - it works well on Ubuntu provided by GCP however you can try out various solutions and pick the one that suits your needs the best.
From my experience - I was using screen for many things - including virtualbox and it worked - it may be more cumbersome if you want many processes to run in background but if that's just one its pretty easy.
Install screen: sudo apt install screen, run it with screen and treat it as another screen, run whatever you want and then just press ctrl + a d and you will be back to "original" shell. If you want to resume yor screen sessions type screen -r. You will find even more about using screen here.

running node js app in background in ubuntu

I have a nodejs compiled application that I run from a terminal window on my ubuntu vps.Is there a way to run it in the background, meaning i can afford to close my terminal window and it still works. Note this exe prints the messages on the terminal window when its running
tried PM2, it errors out saying "awaiting restart"
tried nohup, it does not error out and shows process has started but exe does not what it shall do, meaning its not working.
if i do ./app , it works but then i can not close the terminal window.
used tmux, loving it so far.
think might use PM2 with tmux where i can.

How can I run a node app from the command line and return control?

I run a angular app like this:
npm run server-java
From a terminal window.
The server starts, but I want it to give back the shell prompt.
I want the shell prompt back while it runs.
You can use tools like pm2 or forever to start your nodejs app as a background process. Usually used for production setup.
Another option is:
npm run server-java > /dev/null 2>&1 &
You will get back to the terminal, but then you have to kill process manually by id when you don't need it.

How to keep MEAN (stack) running?

I'm using grunt to run the MEAN project on Ubuntu, but when I close the putty (I use putty to connect Ubuntu server from my PC), it would close the program too.
My question is how can I keep MEAN running?
Update: nohub grunt & stops after I close putty
There are various node based process managers which can serve your task. My favorite is pm2 (http://pm2.keymetrics.io/)
Package managers allow your program to keep running even in case of hiccups. They can watch your project directories for any changes that you might push to them and restart servers based on those changes.
Other favorite is forever (https://www.npmjs.com/package/forever).
you need to run the command in background and I would also recommend to use nohup so:
nohup grunt &
should do the trick.
https://en.wikipedia.org/wiki/Nohup
NODE_ENV=staging nohup node appStag.js &
You can use the above command to run node server
and you can get the above environment using process.env.NODE_ENV
I found a npm package called forever is a good solution, I use forever to run the program right now; and it works perfect with putty.

xfce-session without panels on cygwin

My cygwin workflow is as follows
Run XServer
Start xfce session (by running xfce4-session)
Start xfce4-terminal
Everything works well, except that xfce4-session seems to bring up an empty floating-panel, which I'm unable to hide without killing the session itself. Is there a way to configure xfce so this panel doesn't get shown?
PS: Running xfce4-terminal by itself gives me the terminal emulator, but the terminal behaves nicer when xfce4-session is active--text is anti-aliased, icons are slicker, etc.
Try killing just the panel process itself:
killall xfce4-panel
I believe the right way to start xfce is running /usr/bin/startxfce4.
If you want to run it the way you are, perhaps you could right click on the panel and click remove to get rid of it.
xfwm4 is the Window Manager, xfce-session is the session manager which "Restores your session on startup and allows you to shutdown the computer from Xfce."
I just found out that running xfsettingsd will load the XFCE theme and settings.
Using that command you can initiate the XFCE configuration without running the full desktop environment.
xfsettingsd &; xfce4-terminal;

Resources