Lab no 15 : devapp01 start the webserver

hi @vijin.palazhi

All labs till lab no 14 are successful in checks ( green ) but on lab no 15 after issuing the required commands it does not pass the required checks and gives following error.

After clicking on project mercury tab nothing is visibile specific to application or what is expected .
Can you please guide what is missing here ?

Lab : Troubleshooting the devapp

Great! Everything should now be in order to restart the application.
On the devapp01 start the webserver again by running the command:

Navigate to the directory /opt/caleston-code/mercuryProject
Next, run the command python3 manage.py runserver 0.0.0.0:8000

This should have been successful now.
To access the application, click on the Project Mercury tab!

Tasks not completed!
Task completed?
Command ‘docker exec -w /questions test_infra pytest test_django.py’ returned non-zero exit status 1.

Something is wrong! Is the application running?

logs

Output

ob@devapp01:/opt/caleston-code/mercuryProject$ python3 manage.py runserver 0.0.0.0:8080
Watching for file changes with StatReloader
Performing system checks…

System check identified no issues (0 silenced).
June 10, 2020 - 15:41:17
Django version 2.2.6, using settings ‘mercury.settings’
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.


Hi Pradeep,

I think you have the wrong port here. It should be 8000 not 8080.

Can you try again?

Regards,
Vijin

@vijin.palazhi

Thanks for spotting the error at my end .

I started all labs from start and reached the same point with right port 8000 this time .
All task till now are completed as expected and results were green ( all checks PASS )

This time I am getting error message " ModuleNotFoundError: No module named ‘wordcountbasic’ "

At the same time I am unable to see anything on the tab “project-mercury” on port 8000

I also logged into devdb01 to check whether the postgresql.service is running and it is " active " there .
I have attached those outputs as well.

Sorry I am not from linux / application background hence not able to understand how to fix these myself but eager to learn.

Great! Everything should now be in order to restart the application.
On the devapp01 start the webserver again by running the command:

  1. Navigate to the directory /opt/caleston-code/mercuryProject
  2. Next, run the command python3 manage.py runserver 0.0.0.0:8000

This should have been successful now.
To access the application, click on the Project Mercury tab!

Check

  • Tasks not completed!

  • Task completed?

Command ‘docker exec -w /questions test_infra pytest test_django.py’ returned non-zero exit status 1.

Something is wrong! Is the application running?

logs

===============================================================


Output from the terminal

bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ sudo python3 manage.py runserver 0.0.0.0:8000
Traceback (most recent call last): File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 323, in run_from_argv
self.execute(*args, **cmd_options) File “/usr/local/lib/python3.6/dist-packages/django/core/management/commands/runserver.py”, line 60, in execute
super().execute(*args, **options) File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 364, in execute
output = self.handle(*args, **options) File “/usr/local/lib/python3.6/dist-packages/django/core/management/commands/runserver.py”, line 67, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 79, in getattr
self._setup(name)
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 66, in _setup
self._wrapped = Settings(settings_module)
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 157, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 941, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘wordcountbasic’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “manage.py”, line 21, in
main()
File “manage.py”, line 17, in main
execute_from_command_line(sys.argv)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/init.py”, line381, in execute_from_command_line
utility.execute()
File “/usr/local/lib/python3.6/dist-packages/django/core/management/init.py”, line375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 336, in run_from_argv
connections.close_all()
File “/usr/local/lib/python3.6/dist-packages/django/db/utils.py”, line 219, in close_all
for alias in self:
File “/usr/local/lib/python3.6/dist-packages/django/db/utils.py”, line 213, in iter
return iter(self.databases)
File “/usr/local/lib/python3.6/dist-packages/django/utils/functional.py”, line 80, in get
res = instance.dict[self.name] = self.func(instance)
File “/usr/local/lib/python3.6/dist-packages/django/db/utils.py”, line 147, in databases
self._databases = settings.DATABASES
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 79, in getattr
self._setup(name)
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 66, in _setup
self._wrapped = Settings(settings_module)
File “/usr/local/lib/python3.6/dist-packages/django/conf/init.py”, line 157, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 941, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘wordcountbasic’
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ pwd
/opt/caleston-code
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ whoami
bob
bob@devapp01:/opt/caleston-code$ ls -al
total 40
drwxr-xr-x 7 mercury bob 4096 Apr 15 05:22 .
drwxr-xr-x 1 root root 4096 Jun 11 07:58 …
drwxr-xr-x 8 mercury bob 4096 Apr 15 05:22 .git
-rw-r–r-- 1 mercury bob 1998 Apr 15 05:22 .gitignore
drwxr-xr-x 3 mercury bob 4096 Apr 15 05:22 .idea
-rw-r–r-- 1 mercury bob 7 Apr 15 05:22 README.md
-rw-r–r-- 1 mercury bob 0 Apr 15 05:22 db.sqlite3
-rw-r–r-- 1 mercury bob 634 Apr 15 05:22 manage.py
drwxr-xr-x 7 mercury bob 4096 Apr 15 05:22 mercuryProject
drwxr-xr-x 2 mercury bob 4096 Apr 15 05:22 templates
drwxr-xr-x 3 mercury bob 4096 Apr 15 05:22 venv
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ date
Thu Jun 11 08:48:19 UTC 2020
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ ps -a
PID TTY TIME CMD
433 pts/0 00:00:00 ps
bob@devapp01:/opt/caleston-code$
Jun 11 07:52:57 devapp01 kernel: vda: vda1

bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$
bob@devapp01:/opt/caleston-code$ ssh devdb01
bob@devdb01’s password:
Permission denied, please try again.
bob@devdb01’s password:
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64)

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the ‘unminimize’ command.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.


( ____ ( ___ )( \ ( ____ ( ____ \__ /( ___ )( ( /|
| ( /| ( ) || ( | ( /| ( / ) ( | ( ) || \ ( |
| | | (
) || | | (_ | (_____ | | | | | || \ | |
| | | ___ || | | ) (___ ) | | | | | || (\ ) |
| | | ( ) || | | ( ) | | | | | | || | \ |
| (/| ) ( || (/| (//_) | | | | () || ) \ |
(
/|/ |(/(/_) )( (______)|/ ))

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Last login: Thu Jun 11 08:32:59 2020 from 172.16.239.2
bob@devdb01:~$
bob@devdb01:~$
bob@devdb01:~$
bob@devdb01:~$ sudo systemctl status postgresql.service
[sudo] password for bob:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enable
Active: active (exited) since Thu 2020-06-11 08:10:22 UTC; 44min ago
Process: 321 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 321 (code=exited, status=0/SUCCESS)

Jun 11 08:10:22 devdb01 systemd[1]: Starting PostgreSQL RDBMS…
Jun 11 08:10:22 devdb01 systemd[1]: Started PostgreSQL RDBMS.
lines 1-8/8 (END)
Jun 11 07:52:57 devapp01 kernel: [TTM] Initializing DMA pool allocator

Hi Pradeep, I believe you are not running the start command from:
/opt/caleston-code/mercuryProject, please make sure you change directory to this.

1 Like

hi @vijin.palazhi

Thank you for pointing out my mistakes.
I fixed it and now I am able to complete all tasks of all labs successfully till the end .

Really using animation , "slow speed "during course narration , simple english and periodic labs on small topics and support community like this makes this course unique and amazing.

Is there any chance in near future we can expect further advanced course in Linux or
“Red Hat Certification for Linux” etc course like these which have more acceptance in Industry ?

Looking forward for more and more detailed and amazing courses from you going forward .

Also will highly recommend your course in all my social and offcial circle to profit from this amazing training course and nice community support.

If I can be of any help with my little contribution please do let me know.

I will continue going through each of every other module of Kodekloud and will try to come up with queries if I have any on other modules too.

Thanks again

with best regards
Pradeep Nehe

========= Output from the last task of this lab ========================================

bob@devapp01:/etc/systemd/system$ cat mercury.service
[Unit]
Description=Project Mercury Web Application
[Service]ExecStart=/usr/bin/python3 manage.py runserver 0.0.0.0:8000
Restart=on-failure
WorkingDirectory=/opt/caleston-code/mercuryProject
User=mercury

[Install]
WantedBy=multi-user.target

bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ sudo systemctl status mercury.service
● mercury.service - Project Mercury Web Application
Loaded: loaded (/etc/systemd/system/mercury.service; disabled; vendor preset: enabled)
Active: inactive (dead)
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ sudo systemctl start mercury.service
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ sudo systemctl status mercury.service
● mercury.service - Project Mercury Web Application
Loaded: loaded (/etc/systemd/system/mercury.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2020-06-13 00:00:35 UTC; 1s ago
Main PID: 398 (python3)
Tasks: 3 (limit: 3546)
CGroup: /system.slice/containerd.service/system.slice/mercury.service
├─398 /usr/bin/python3 manage.py runserver 0.0.0.0:8000
└─400 /usr/bin/python3 manage.py runserver 0.0.0.0:8000

Jun 13 00:00:35 devapp01 systemd[1]: Started Project Mercury Web Application.
Jun 13 00:00:35 devapp01 python3[398]: Watching for file changes with StatReloader
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ sudo systemctl enable mercury.service
Created symlink /etc/systemd/system/multi-user.target.wants/mercury.service → /etc/systemd/system/mercury.service.
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ ls -al
total 24
drwxr-xr-x 1 root root 4096 Jun 12 23:57 .
drwxr-xr-x 1 root root 4096 Feb 24 14:18 …
lrwxrwxrwx 1 root root 44 Feb 24 14:18 dbus-org.freedesktop.resolve1.service → /lib/systemd/system/systemd-resolved.service
lrwxrwxrwx 1 root root 37 Apr 17 00:26 default.target → /lib/systemd/system/multi-user.target
-rw-r–r-- 1 root root 244 Jun 12 23:57 mercury.service
drwxr-xr-x 1 root root 4096 Jun 13 00:01 multi-user.target.wants
lrwxrwxrwx 1 root root 31 Apr 14 06:01 sshd.service → /lib/systemd/system/ssh.service
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$
bob@devapp01:/etc/systemd/system$

how to run a mercury.service as mercury user in last task

Hi @navin

These are the commands / steps which I executed and it worked for me successfully .
Above output is detailed one based on these commands.

bob@devapp01:/etc/systemd/system$ cat mercury.service

bob@devapp01:/etc/systemd/system$ sudo systemctl status mercury.service

bob@devapp01:/etc/systemd/system$ sudo systemctl start mercury.service

bob@devapp01:/etc/systemd/system$ sudo systemctl status mercury.service

bob@devapp01:/etc/systemd/system$ sudo systemctl enable mercury.service

bob@devapp01:/etc/systemd/system$ ls -al

bob@devapp01:/etc/systemd/system$ echo PATH

with best regards
Pradeep Nehe

thank you @ppnehe for answering

with regards
Navin Patil