Restart Django Service
I use marketplace to install django, after successfull installed it was working fine with node ip but after restart node it is not working, how can restart django service ? and what is default django service to make restart ?
3 Replies
I created a Django server from the Marketplace App and I didn't see issues when rebooting it from Cloud Manager, the CLI, or the command line. While I wasn't able to recreate what you're seeing, I took steps to kill the process to test bringing it back up.
There should be a line in /var/spool/cron/crontab/root
that says
@reboot cd /var/www/DjangoApp && python3 manage.py runserver 0.0.0.0:8000 &
That line will run python3 manage.py runserver 0.0.0.0:8000 &
from the directory /var/www/DjangoApp
at reboot, so I just did the two commands separately and it got my site back up. The ampersand is causing it to run in the background. You'll just need press return
after you see output that ends with Quit the server with CONTROL-C
. If you press CONTROL-C your site will go back down, but pressing enter will force it to the background so you can do other things with the command line.
While I hope that helps in the short-term, I'm still not sure why it might need to be restarted. I'd investigate why it's not coming up further by checking log files. I found this guide for setting up logging with Django. You can also check out this post on our Community Site about checking log files. Hopefully that helps you find a longer term solution after identifying the issue.
If that doesn't work, you may want to check out some of our troubleshooting guides. It's possible there are issues with memory or your networking configurations or other things that are causing this problem and these guides will help you identify that cause.
Troubleshooting Firewalls
Troubleshooting Web Servers, Databases, and Other Services
Troubleshooting Basic Connection Issues
Troubleshooting Memory
How do I understand the results of an nmap scan
I'm not able to say for sure why that happened, but my guess would be that something interrupted the Marketplace App's StackScript before it had a change to complete.
You have a few options. If you haven't done too much work on this yet, I'd recommend just deploying a new app and making sure it's completed before doing anything else with it. You can check this by looking in the log file to see if you see "installation complete!" If it worked as intended, it should look like this:
grep -i 'installation complete' /var/log/stackscript.log
Installation complete!
If you'd like to just add the file to the current instance, I confirmed that's possible by deleting my own and adding it back. As long as it's got the proper permissions and ownership, it will bring the site back up on reboot. To do this, you can run the following commands. You may need to use sudo if you're not logged in as root:
cd /var/spool/cron/crontabs
nano root
Then copy and paste the following line into the file:
@reboot cd /var/www/DjangoApp && python3 manage.py runserver 0.0.0.0:8000 &
Press ^x
to exit and save the file, then run the following commands to set the permissions and group:
chmod 600 root
chgrp crontab root
If you run ls -la
from your working directory, you should now be able to see this line (though with a different date):
-rw------- 1 root crontab 76 Sep 22 15:04 root
While this does the job, I can't promise this is the best way to do this and I think a new instance would likely be the best bet. This may not be the only thing that got messed up and you could end up doing less work in the long run starting over. I hope this helps!