Rex,
As Priscilla mentioned, there are numerous trains on that route every day, so don't be too concerned about how long it will take to disembark from the ship. Get off the ship whenever it's convenient, go to the nearest rail station and buy a ticket on the next train to Ravenna.
There's no need to buy a ticket in advance since most of the trains on that route will include one segment via Regioinale train. It's possible that one of the segments will be via Freccia or other "fast" train that requires a compulsory seat reservation. If unloading from the ship takes longer than expected and you miss that train that you booked, the ticket would be worthless and you'd have to buy another one anyway.
I've never taken a cruise in that part of the world, so I don't know which rail station you'll be closer to, but you'll be able to buy tickets regardless.
One important point to mention. You MUST validate your tickets prior to boarding a Regionale train on the day of travel, or risk hefty fines which will be collected on the spot!