How to make SMF service start last?

I need to start a service among the last on a freshly booted system. Via the manifest, I've made it dependent on very milestone on the computer yet the service still comes back with an error that a kstat variable in the kernel does not exist.

I run it right the service process right there and then and it works fine. So, there is something that sets-up kstat and this kernel variable after my service is trying to run on boot-up.

Isn't there something I can do to tell SMF run every single service on boot-up before you run my service?

Identify what service (if any) is setting that variable and make your service dependent on it. If not a service, create one or add it to yours.

Thank-you. I thought of that and did the research trying to find what service would provide the kstat kernel variable ... no luck. It's inode_cache, so I would've thought anything to do withe the file system would work.

I hoped making my service depend on every freaking SMF milestone would do the job - no luck.

What I finally did was change the program of my service to sleep for 10 seconds - it gives SMF the illusion it is up and running while SMF starts-up other services. By the time my service wakes up again, the system is actually ready for it.

A hack job yes, but better than the hours I have already put in trying to solve a simple problem.

SMF may be an improvement, but taking away the ability to simply say I want my service to start last (as much as it can), is too much.

With smf, services are launched in parallel so their order is not deterministic meaning unlike with System V init.d jobs, there is no "last service".

Are you booting on ZFS ?

Not even dependencies, like waiting for network to come up before launching network services?

Dependencies are of course deterministic. My point was unlike with System V init.d commands, there is no visible linear path based on files being sorted by their "SXXname" and "KXXname" so a S99zz services would likely run after all the other ones.

With smf, there is then no deterministic last service unless it explicitly states it depends on each other ones using the optional_all tag to ignore explicitly disabled services.

Of course there is always an option to use legacy way inside smf (lrc)

According to documentation (haven't tested this), legacy scripts always run last on boot (after smf services) and are first to stop on shutdown (before smf).