No person shall be discharged from an order of commitment issued by any judicial or peace officer for want of bail, or in cases not bailable on account of any defect in the charge or process, or for alleged want of probable cause; but in all cases the court or judge shall summon the prosecuting witnesses, investigate the criminal charge, and discharge, admit to bail or recommit the prisoner, as may be just and legal, and recognize witnesses when proper.