Hi,
as a first step, you should just run
$ sudo service tomcat restart
Wait for the prompt to get back (Tomcat restart could take some seconds), and then run
$ sudo /etc/init.d/postgresql restart
Running those simple commands is enough for tomcat and postgres to restart.