Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring automatic start/stop of postgresql service upon activating the environment #2

Open
alfredoq opened this issue Nov 1, 2024 · 0 comments

Comments

@alfredoq
Copy link

alfredoq commented Nov 1, 2024

Hi,

I was following the installation instructions provided for the ChEMBL database in a local computer (here).

Facing the requirement to start the postgresql service, two options are suggested:

1- start it manually upon every computer reboot (not so comfortable).
2- start it automatically upon system start by creating a startup script (maybe undesired if preferring to save computer resources in case no action related to the use of postgresql service is expected).

a third option may be included, which in my case worked out as the optimal: start postgresql service upon environment activation / stop postgresql service upon exiting the environment.

I was able to successfully configure those actions following this documentation and the following procedure:

  • with the corresponding environment activated, determine the ${CONDA_PREFIX} variable;
  • next, create the corresponding start/stop scripts in the directories CONDA will use to autostart/autostop:
foo@bar:~$ mkdir -p ${CONDA_PREFIX}/etc/conda/activate.d
foo@bar:~$ mkdir -p ${CONDA_PREFIX}/etc/conda/deactivate.d
foo@bar:~$ echo "sudo service postgresql start" ${CONDA_PREFIX}/etc/conda/activate.d/start_postgresql.sh
foo@bar:~$ echo "sudo service postgresql stop" ${CONDA_PREFIX}/etc/conda/deactivate.d/stop_postgresql.sh

With that configuration the service starts and stops as expected,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant