NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Start PostgreSQL on startup

Hello,

 

I have successfully installed Postgresql on a sbRIO board by largely following this guide https://forums.ni.com/t5/NI-Linux-Real-Time-Documents/Tutorial-PostgreSQL-with-LabVIEW/ta-p/3491581?... . Like in the guide, I have to enter the command “ulimit -s 2048” to be able to start the database and communicate with.

However, when I restart the sbRIO, I have to re-enter the command “ulimit” again and restart the server.

 

I would like to make it that the database starts on its own when the board is powered.

 

I tried to add the line “* soft stack 2048” at the end of the file limits.conf as mentioned by the person writing the last message, but without success. The parameters of this file do not seem to be considered on reboot.

 

Would there be another file to modify or another way? One idea would be to write a script, but I was wondering if there was a “simpler” way because the script would require to log as admin to change the "ulimit" and relog as the postgres user to start the database and I feel like it is a bad idea to play with the users like that.

 

Thank you!

0 Kudos
Message 1 of 5
(2,414 Views)

Current versions of Linux Real-Time use the System V Init system (SysVinit). I'd recommend referring to the public documentation for creating init scripts with System V in order to have the service/daemon start on boot. You can include the ulimit command you need in the init script to ensure it's applied each time. 

Charlie J.
National Instruments
Message 2 of 5
(2,391 Views)

Thank you Charlie

 

I tried to use the method you suggested but I hit a problem. It look like the "ulimit" command, when used in a shell script, change the parameters only for that shell. So, once the script is done, I find the same parameters as before in the original shell. 

 

I tested it using the command "prlimit --stack" before/after "ulimit" and in/out of the script.

 

Did I miss something?

 

- Dave

 

0 Kudos
Message 3 of 5
(2,354 Views)

You are correct that the ulimit setting does not apply to the original shell but I believe it does apply to any child processes created by the initialization script. That is, I think the service you start will run with the appropriate settings.

 

EDIT: You can check the limits of a running process via 'cat /proc/<pid of process>/limits' where the stack size corresponds to the -s flag. 

Charlie J.
National Instruments
Message 4 of 5
(2,345 Views)

Hello Charlie,

 

Finally, we were able to modify the parameter "max_depth_stack" in the postgresql configuration file to a value not giving errors.

 

With that problem solved, we were able to use your suggestion to launch the process during the startup!

 

Thank you very much!

 

 

0 Kudos
Message 5 of 5
(2,313 Views)