[go-nuts] Re: Handling multiple things happening at the same time

2016-09-11 Thread Matt Davies
Thanks for everyones help. I'm going to go with the subroutine for now. This is all the app does, download a file, manipulate it, then serve it up for pick up. It does the download and manipulate action once a day, and the upload happens once a day. We've got raven emailing us if anything goe

Re: [go-nuts] Re: Handling multiple things happening at the same time

2016-09-10 Thread Asit Dhal
Hi, Don't you think it will be over engineering. Like Simon said, Apache can be used as a file transfer app(it has logging, loading, restarting). Probably, his small app is an extension of some bigger go app. His small app can use two different processes which runs under two different user(

[go-nuts] Re: Handling multiple things happening at the same time

2016-09-10 Thread Caleb Doxsey
Why would you do this manually? You should use systemd to create a service. It will handle starting on load, logging, restarting when it crashes, etc. On Saturday, September 10, 2016 at 7:06:03 AM UTC-4, Simon Ritchie wrote: > > > maybe gocron can schedule the http.ListenAndServe to run all the

[go-nuts] Re: Handling multiple things happening at the same time

2016-09-10 Thread Simon Ritchie
> maybe gocron can schedule the http.ListenAndServe to run all the time? The classic solution (which is how the Apache web server does it) is to have a shell script that loops forever, starting the web server, waiting for it to finish and starting it again. So, if the server crashes, the paren

[go-nuts] Re: Handling multiple things happening at the same time

2016-09-10 Thread Simon Ritchie
I agree with Asit, but I would go further. You have one thing that is fetching files and putting them in a directory. You have another thing that is exposing the files in a directory via a web interface. Except that they happen to be working on the same directory, there is no connection betw

[go-nuts] Re: Handling multiple things happening at the same time

2016-09-09 Thread Caleb Doxsey
It looks like gocron.Start() runs the jobs in another goroutine, so you can just do both things in your main function: func main() { s := gocron.NewScheduler() s.Every(3).Seconds().Do(task) stopper := s.Start() defer close(stopper) err := http.