Linux nohup crashing MySQL Server
Linux nohup crashing MySQL Server
Author
Discussion

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
Okay, long story short a few months back I asked how we could run our server without it hanging up when I left git bash and someone told me to use this:

nohup python app.py > /dev/null 2>&1 &

But now to run the MySQL Server in the background for workbench, I added this 'runserver ' statement.

nohup python app.py > /dev/null 2>&1 runserver &

This causes the server to not handle database related tasks after a period of inactivity.

Is there a way we can fix this issue or operate both tasks?

Any help is appreciated



Edited by CasioPasio on Wednesday 3rd October 13:19

4x4Tyke

6,506 posts

163 months

Wednesday 3rd October 2018
quotequote all
MySQL is probably timing out the connections.

https://dev.mysql.com/doc/refman/8.0/en/server-sys...

nyt

1,941 posts

181 months

Wednesday 3rd October 2018
quotequote all
Does

nohup runserver > /dev/null 2>&1 &

work?

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
nyt said:
Does

nohup runserver > /dev/null 2>&1 &

work?
Tried that now, no luck. It gives me a message telling me to run MySQL.

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
4x4Tyke said:
MySQL is probably timing out the connections.

https://dev.mysql.com/doc/refman/8.0/en/server-sys...
I was thinking the same thing because previously didn't have this and it worked fine.

buggalugs

9,297 posts

268 months

Wednesday 3rd October 2018
quotequote all
CasioPasio said:
Okay, long story short a few months back I asked how we could run our server without it hanging up when I left git bash and someone told me to use this:

nohup python app.py > /dev/null 2>&1 &

But now to run the MySQL Server in the background for workbench, I added this 'runserver ' statement.

nohup python app.py > /dev/null 2>&1 runserver &

This causes the server to not handle database related tasks after a period of inactivity.

Is there a way we can fix this issue or operate both tasks?

Any help is appreciated



Edited by CasioPasio on Wednesday 3rd October 13:19
There's something I don't understand, what is runserver? Don't you normally just go mysqld --daemonize or use the supplied init files?

4x4Tyke

6,506 posts

163 months

Wednesday 3rd October 2018
quotequote all
buggalugs said:
There's something I don't understand, what is runserver? Don't you normally just go mysqld --daemonize or use the supplied init files?
I'm assuming that is his startup script, and its running it in the local context and dropping to the defaults.

@op, have you tried piping the output to a text file to see if you get some meaningful feedback?

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
4x4Tyke said:
I'm assuming that is his startup script, and its running it in the local context and dropping to the defaults.

@op, have you tried piping the output to a text file to see if you get some meaningful feedback?

GrumpyTwig

3,354 posts

188 months

Wednesday 3rd October 2018
quotequote all
At best this should be setup in systemd or init, at worst you could use supervisord instead. Running things in unmonitored disowned shell jobs is just asking for a pita.

Maybe try this:

nohup sh -c 'runserver && python app.py' > /dev/null &
but please consider not doing it this way. plllllzzzz


Looking at the above though has app.py changed? it looks like it's expecting an argument. You might need to share the content of 'runserver'.

Edited by GrumpyTwig on Wednesday 3rd October 15:58

MagicalTrevor

6,481 posts

260 months

Wednesday 3rd October 2018
quotequote all
As above, use systemd for this, it's the correct way to do it.

https://dev.mysql.com/doc/refman/8.0/en/using-syst...

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
GrumpyTwig said:
At best this should be setup in systemd or init, at worst you could use supervisord instead. Running things in unmonitored disowned shell jobs is just asking for a pita.

Maybe try this:

nohup sh -c 'runserver && python app.py' > /dev/null &
but please consider not doing it this way. plllllzzzz


Looking at the above though has app.py changed? it looks like it's expecting an argument. You might need to share the content of 'runserver'.

Edited by GrumpyTwig on Wednesday 3rd October 15:58
Hey thanks for the input. I tried that but I get this:



How would you suggest we get this server setup for the long run? I've looked around but most tutorials seem to be for 'testing' purposes and not for a real production enviroment

TooLateForAName

4,935 posts

215 months

Wednesday 3rd October 2018
quotequote all

does this work?

nohup python app.py runserver > /dev/null 2>&1 &

but as above - do it properly. If this is commercial get someone in for a day to check over what the server is intended to do and make it use proper admin tools.

rxtx

6,053 posts

241 months

Wednesday 3rd October 2018
quotequote all
MySQL should come with init scripts, how did you install it?

Never use nohup, it's never the correct choice for anything live. If your Python script runs as a daemon, it too will need an init script. It might be systemd, might not.

GrumpyTwig

3,354 posts

188 months

Wednesday 3rd October 2018
quotequote all
CasioPasio said:
GrumpyTwig said:
At best this should be setup in systemd or init, at worst you could use supervisord instead. Running things in unmonitored disowned shell jobs is just asking for a pita.

Maybe try this:

nohup sh -c 'runserver && python app.py' > /dev/null &
but please consider not doing it this way. plllllzzzz


Looking at the above though has app.py changed? it looks like it's expecting an argument. You might need to share the content of 'runserver'.

Edited by GrumpyTwig on Wednesday 3rd October 15:58
Hey thanks for the input. I tried that but I get this:



How would you suggest we get this server setup for the long run? I've looked around but most tutorials seem to be for 'testing' purposes and not for a real production enviroment
 nohup sh -c 'runserver && python app.py' > /dev/null 2>&1 & 


But as above, it needs setting up with systemd/init. Please don't take offence but maybe you need to engage the services of someone with the know how to do this.

If you can tell us what distro and version you're one it might be possible to point you in the direction of a workable tutorial.

Edited by GrumpyTwig on Wednesday 3rd October 19:52

Mgd_uk

412 posts

135 months

Wednesday 3rd October 2018
quotequote all
You could as a temp measure run it in “screen”

Yum install screen
Or
Apt install screen


Type screen

Run your python script

Ctrl + D to detach

You can then logout or close the session and screen will keep your service running in the background.

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
TooLateForAName said:
does this work?

nohup python app.py runserver > /dev/null 2>&1 &

but as above - do it properly. If this is commercial get someone in for a day to check over what the server is intended to do and make it use proper admin tools.
Tried it, that doesn't work either. It tells me to use 'runserver' as above.

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
rxtx said:
MySQL should come with init scripts, how did you install it?

Never use nohup, it's never the correct choice for anything live. If your Python script runs as a daemon, it too will need an init script. It might be systemd, might not.
sudo apt-get install mysql-server

We need a temporary solution until we can get someone in.

CasioPasio

Original Poster:

227 posts

111 months

Wednesday 3rd October 2018
quotequote all
GrumpyTwig said:
 nohup sh -c 'runserver && python app.py' > /dev/null 2>&1 & 


But as above, it needs setting up with systemd/init. Please don't take offence but maybe you need to engage the services of someone with the know how to do this.

If you can tell us what distro and version you're one it might be possible to point you in the direction of a workable tutorial.

Edited by GrumpyTwig on Wednesday 3rd October 19:52
I don't take offense smile I've had to learn this in a couple of days, it's not my playing field.

I spoke to someone and they said somewhere between £500 to a £1000 for a 1 day and it would be done. At this early stage in the company, we don't want to make a that sort of investment yet.

So I think maybe just having it not cut out for now would be a good start until we progress further.

buggalugs

9,297 posts

268 months

Wednesday 3rd October 2018
quotequote all
A grand to get MySQL to work, Jesus I feel like I’ve wasted my life

A lot of providers will do MySQL as a service, rackspace AWS Azure Linode basically all of them, might that be a way forward?

If you can do a python app you should be able to get a set of systemd scripts running - #devops biggrin

ging84

9,548 posts

177 months

Wednesday 3rd October 2018
quotequote all
Anyone want to take a bet on if runserver is a hacky script running a world accessible mysql server with no authentication?