Using Huey with Django: How to keep run_huey command running? - python-huey

I'm using Django on Ubuntu 18.04.
I've got everything set up. And I type python manage.py run_huey in the server (through an SSH connection) to start huey, and it works.
However this is done through the command line through SSH and it will shut off when I close the SSH connection.
How do I keep run_huey running so that it will stay active at all times? Furthermore, after a system reboot, how do I get run_huey to automatically start?

You may explore supervisorctl utility for ubuntu, it keeps process running and can log into file and any other features. Google it.

Related

Start node app through ssh, stays running?

I have a raspberry PI on which I run a node server. To start and control the terminal on which the server runs I use desktop remote to remote control the raspberry. Now this method is really slow so I was wondering, since I only need a command line anyway if I couldn't just connect to my raspberry pi using ssh for example.
My question now, would be if I do so, can I navigate to my node folder, run my node file and then close the ssh connection? Will my Node server keep running and if so how would I access the terminal with the node session after closing the connection?
The easiest way to do this is something like:
nohup node myapp.js &
This will make the app run in the background, and nohup prevents it from stopping when the connection closes.
This is a cheap and quick way to do this. A more appropriate way might be one of the following:
Using something like docker to manage running applications.
Using something like supervisord to do the same thing.
Writing scripts for initd and turn it into a real 'service'.
Changing the node application to fork & deamonize itself.

Nodejs application session is not alive after closing putty terminal even after using nohup command in manage hosting server

I have an application running on a managed server. I deployed the application after many hurdles but now the problem is that the application process is killed once i close the putty terminal.
I was suggested to use the following command to run the process in background, but this command is not doing any help?
nohup npm start --production &
I have googled and people have suggested to use screen, but i want to avoid using it because installing new packages brings new challenges to my app (i am new to nodejs deployment)
My Question : What is the problem in nohup command ?
My nohup.out file :
Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale
past a single process. connected as id 2515208
OK so i used screen. It was pre installed on server , i just need to use it by calling a couple of commands.
Its easy to use and my application is working fine till now.
But still i want to know what nohup does ? because it was useless for me.

How to execute a shell script after oracle started successfully

I would like to execute a shell script with non-root user while Linux system booting and oracle has been started successfully.
I tried to execute this shell in rc.local. But I found oracle start-up procedure took too much time. So when shell tried to connect to Oracle, it return failed.
On the user`s Linux server, it took several minutes to get Oracle running. I am not clear what technology they use. I found when Oracle didn`t startup finished, I can login Linux server through ssh.
In my opinion, Linux boot sequence should like following.
/etc/rc.d/rc.sysinit
/etc/rc.d/rc $RUNLEVEL
/etc/rc.d/rc.local
/bin/login
But If I add line to check if Oracle is running in rc.local, user cannot login Linux server for several minutes. I think it is improper.
Is there a better solution to solve this problem?
Any suggestion is welcome.
Use one of this solutions and configure it to "wait" for oracle listen port.
https://github.com/vishnubob/wait-for-it
Or
https://github.com/Eficode/wait-for

Unable to restart rogue Jenkins on Ubuntu

I was configuring Jenkins last night to run some reporting plugins (codestyle, findbugs, cobertura). When I ran my build job it got hung up somewhere in codestyle, and the server ui became unresponsive.
Today I logged in to the server and the Jenkins log is reporting errors that look like the server ran out of memory, but more than that, I cannot seem to stop or restart the server. I have limited experience with services in linux.
Jenkins was installed on Ubuntu with atp. I have tried $ sudo /etc/init.d/jenkins restart but it reports
* Starting Jenkins Continuous Integration Server jenkins
The selected http port (8080) seems to be in use by another program
Please select another port to use for jenkins
When I try to run service jenkins status to get a pid to kill i get
2 instances of jenkins are running at the moment
but the pidfile /var/run/jenkins/jenkins.pid is missing
Running netstat and ps has identified the port being held by a jenkins instance.
How can I recover from this?
Mostly I was concerned about abruptly killing the Jenkins server while it has gone rogue. Something this tied into process with server connections and plugins makes me wary of taking a shotgun to the process.
That's exactly what I did. server jenkins status didn't work, so I got the process id from netstat -tulpn. kill -15 didn't work so I did kill -9, waited a respectful grieving period, then restarted the Jenkins service.
I will next be investigating the root problem of running out of memory in my Jenkins installation so hopefully this doesn't happen again while I am firewalled away from my server.
Where is your server hosted?
I had the same issue with AWS EC2 server.
Command lines did not work to reboot the server.
However, on AWS admin console, I did: EC2 -> restart and it works like a charm.
This may not be a solution but a workaround.
I was able to do
sudo ps aux | grep jenkins
To find a list of jenkins processes. Then I ran
sudo kill <pid>
And then finally
sudo service jenkins restart

Quitting ssh -X session with a running GUI program but leaving the program to run on the remote host

I have ssh-ed to a remote machine. I have enabled X11 forwarding (ssh -X) and I have started a GUI program.
The program takes 5 minutes to set up to do some processing but the actual processing takes 1-2 hours. I don't want to stream data while the program is working. I don't even want to see the program again as it produces files as output when it finishes and I can just scp them.
So how can I quit the ssh session but leave the program running on the machine? CRTL+C in the terminal?
EDIT: For the answer please see my comment just below.
Long story short - you can't do this without making some modifications to the way you run things. A GUI application requires for an X server target to be accepting it's GUI updates - if you're using your local X server to do this, then it'll require (1) the connection to be open (2) that you actually handle the updates.
A way around this is to use something like Xvfb - which is a headless way of hosting a virtual X-server. Above and beyond the examples provided on the wikipedia page, folks who seem to make frequent use of this mechanism are Selenium users.
Awesome, I've been looking for an acceptable answer to my problem for hours, and finally one pops up. ssh -X -f login#machine yourprogram worked perfectly for me. Though I used ssh -Y -f login#machine yourprogram. This has been driving me nuts.
Like some people said, SSH -X is using your local X server, so it needs the connection. I had the same problem, wanted to quit ssh but leaving GUI applications running. To do this I installed X server and VNC server on the remote host. With a VNC client on your local computer, you can easily connect to the VNC server and disconnect leaving GUI applications running.
By the way, you will have better performances with VNC or X2Go. In my case, Firefox was very slow and some sites didn't load at all with SSH -X, even with -Y or -C optimizations.
Running ssh -X -f login#machine yourprogram should do the trick.
Starting your program with nohup program & will make it safe to just close your terminal - program will still be running.
You won't be able to see the UI after you end ssh session, but since you don't need it anyway - it's going to do the job.

Resources