Question on user_launch

Is there any documention on how user_launch is working ?

If I understood correctly it allows to start some jobs/services once the system is started like LaunchBox below (which depends on a setting) :

job x-vnd.Haiku-LaunchBox {
	launch /system/apps/LaunchBox
	if setting ~/config/settings/LaunchBox/main_settings autostart
	on initial_volumes_mounted
	legacy
	no_safemode
}

Not sure how the setting command is working and what legacy/safemode mean.

Have a look at The Haiku Book: Introduction to the Launch Daemon

The doc I linked doesn’t specifically mention the condition “setting”.

It appears the “setting” condition in

if setting ~/config/settings/LaunchBox/main_settings autostart

decodes the flattened BMessage ~/config/settings/LaunchBox/main_settings and checks if there’s a field named “autostart” and sees if it’s true or false.

Safenmode is related to booting with safemode from the bootloader. Not sure what legacy means though.

My understanding is that if the service does not use BServer, which is private, then legacy should be used.

I’ve an additional question : the documentation is also referring to “after user login (when it’s in ~/config/data/launch/ )”.

However the directory doesn’t exist, what is the correct directory to add user services/jobs instead of system services/jobs ?

EDIT : maybe /boot/home/config/settings/boot/launch/ ?

The documentation is severely lacking. The launch directory is for system services, the user_launch directory is for user services.

The ~/config/data/launch or user_launch directories will appear as-needed(when a package is installed which contains a file in that directory). However, the directories in ~/config are part of a separate packagefs mount from /system. This means that a package installed to /system/packages will use /system/data/user_launch and a package installed to ~/config/packages will use ~/config/data/user_launch.

Ok maybe I will explain what I have in mind :

Suppose I have installed a package like “postgresql” where the package is not using the “launch daemon” feature.

Is there any possibility to define a user launcher like below without changing the package ?

job.x-vnd.postgresql {
  launch pg_ctl -D /boot/home/postgresql
  no_safemode
  legacy
  on initial_volumes_mount
}

Or maybe it’s better to add a bash script in the /boot/home/config/settings/boot/launch/ folder ?

I’m not sure if I understand the question properly, that “user launcher” is being run by the launch daemon. If you’re talking about creating launch_roster scripts outside of a package, then you can create/use the non-packaged directories. Like, /system/non-packaged/data/user_launch or ~/config/non-packaged/data/user_launch

Ok I’ve created the folder /boot/home/config/non-packaged/data/user_launch and put the script above but it’s not working.

postgresql is not exactly “outside of a package” because it’s installed via pkgman (postgresql12_server), however I would like to enhance it by starting the server via a user_launch :slight_smile:

I was a little bit mistaken, the ~/config/non-packaged/data/user_launch doesn’t appear to be working, but the /system one does. Seems like a bug to me.

The launch script requires some changes too. The job should probably be switched to a service and you have an extra period in there after job, service x-vnd.postgresql. The on statement should be on initial_volumes_mounted. You may need to specify the full path to the pg_ctl command, I’m not sure of that.

Thank you for these details, indeed the folder recognized is “/system/non-packaged/data/user_launch”

I can see that “job” is working with the below :

job x-vnd.postgresql {
  launch /bin/pg_ctl -D /boot/home/postgresql -l /boot/home/postgresql/postgresql.log start
  no_safemode
  legacy
  on initial_volumes_mounted
}
1 Like