Thursday, February 22, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3817  / 11 Months ago, tue, april 25, 2023, 7:09:53

I've an OpenERP server running on one of my servers. It's started by a traditional /etc/init.d/ script. It uses a PostgreSQL database and needs a manual restart every time PostgreSQL is restarted.



Every time Ubuntu releases a security update for PostgreSQL, my OpenERP server becomes non-functional until I ssh to the server and manually run sudo /etc/init.d/my-openerp restart. I usually forget to do that after I do the sudo apt-get upgrade.



Can I configure upstart to do that for me, every time postgresql is restarted by apt?


More From » 12.04

 Answers
7

Since the postgresql server is still using deprecated System-V init script there are two options:




  • Emit events from the existing System-V init script

  • Port existing System-V init script to upstart job



In both cases you can use start on started-postgresql and stop on stopping-postgresql in your job. As mentioned in the comment my-openerp will start/stop always on started/stopped postgresql and not only after upgrade.



If you opt for emitting events from the existing System-V init script you will need to add in /etc/init.d/postgresql:



# just before the service is started
initctl emit starting-postgresql
# just after the service is started
initctl emit started-postgresql
# just before stopping the service
initctl emit stopping-postgresql
# just after the service is stopped
initctl emit stopped-postgresql


For details see Helpful Tips in Writing Services section on Ubuntu Boot up Howto page.



In case that you opt for creating Upstart job the simplest configuration might look like this:



start on runlevel [2345]
stop on runlevel [016]
respawn

exec su -c "/etc/postgresql/bin/postgres -D /usr/local/pgsql/data" postgres


More elaborated Upstart config can be found here.



I would play around and instead of starting postgresql on runlevel [2345] perhaps say



start on filesystem and net-device-up IFACE!=lo


or



start on started networking


You might also consider adding kill timeout stanza



kill timeout 300

[#32708] Wednesday, April 26, 2023, 11 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
urnaetted

Total Points: 10
Total Questions: 113
Total Answers: 117

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;