Recently I ran across some pretty extreme examples of how writers have forced themselves to write: supposedly Victor Hugo had his valet hide his clothing so that Hugo couldn't go out, and Demosthenese shaved his head (actually half of it) so he'd be embarrassed to appear in public and instead spent his time working.
A more modern example: a writer had his wife take the internet router to work with her while he stayed home and wrote.They'd hook it back up when she got back at the end of the day.
More convenient is using RescueTime (they have a free trial, there's a free 'lite' version and a full version for $6-$9/month).Among other useful functions is the ability to block distracting parts of the internet for a period of time you specify. You can also track which applications you are using and which projects you are working on, for how long).
If distraction is an issue, check it out at: https://www.rescuetime.com/rp/j4london
Below the green button you can click to see a video tour or some screenshots to see how it works.
(full disclosure: I like RescueTime enough to have joined as an affiliate--but I only recommend things I use and believe in.)