Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: jessethepro on February 18, 2013, 09:36:03 PM

Title: [SOLVED] POSTGRESQL as a service
Post by: jessethepro on February 18, 2013, 09:36:03 PM
Hi,

I am trying to run postgresql as a service. When run as user tc through ssh script:

PGDATA=/tmp/maxdb
pg_ctl init
/tmp/tcloop/postgresql/usr/local/bin/postgres -D /tmp/maxdb

Runs without issue.

When put into bootlocal.sh service doesn't start. Anyone have success starting postgres on boot as a service?

Respectfully,
Jesse
Title: Re: POSTGRESQL as a service
Post by: tinypoodle on February 18, 2013, 09:51:04 PM
bootlocal.sh runs as root.
When you say ssh script did you perhaps mean sh script?
Title: Re: POSTGRESQL as a service
Post by: gerald_clark on February 18, 2013, 09:56:20 PM
You also should not be referencing /tmp/tcloop/postgresql/
Title: Re: POSTGRESQL as a service
Post by: Rich on February 18, 2013, 10:00:10 PM
Hi jessethepro
I would also question your use of  /tmp/tcloop.   /tmp/tcloop/postgresql/usr/local/bin/postgres is linked to
/usr/local/bin/postgres  and  /usr/local/bin  is in the path.
postgres -D /tmp/maxdb  is all you need.
Title: Re: POSTGRESQL as a service
Post by: jessethepro on February 18, 2013, 10:38:43 PM
Thank you for the great info,

I log in through ssh and run the script with the default shell

I didn't know the path linked to /usr/local/bin. That is great to know.

Changing the start command to postgres -D /tmp/maxdb works perfect when run through the shell,  but won't start when run through bootlocal.sh. If postgres is like mysql, it probably doesn't like being started by root. Is there a way to start a service by user tc through bootlocal.sh?

I tried putting:
echo -e "password for tc" | su tc
Before the postgres commands to switch users and run the last of bootlocal.sh.as user tc, but didn't have much luck with that.

Respectfully,
Jesse
Title: Re: POSTGRESQL as a service
Post by: Rich on February 18, 2013, 10:46:06 PM
Hi jessethepro
This same type of situation came up recently here:
http://forum.tinycorelinux.net/index.php/topic,14573.msg82686.html#msg82686
So maybe something like:
Code: [Select]
su tc -c 'postgres -D /tmp/maxdb'will do what you need.
Title: [SOLVED] POSTGRESQL as a service
Post by: jessethepro on February 20, 2013, 04:45:06 PM
Rich,

The command you gave me worked perfectly. I do appreciate the assistance. For future reference, the complete script in bootlocal.sh to start the postgresql server with default unix sockets is:

Code: (bash) [Select]
export PGDATA=/tmp/maxdb #or any other file path for the database
su tc -c 'pg_ctl init'
su tc -c 'postgres -D /tmp/maxdb'

Thank you again for everyones assistance,
Jesse