Vostok/sigterm example
To go back to Vostok: here.
Introduction
The code here should show the implication of being able to handle "graceful shutdowns" of Vostok servers.
In particular, we want to make sure that all of these process types are gracefully stopped:
- the server's children (handling http requests)
- the server's scheduled job workers
- the server's asynchronously running contexts (routines)
Top
Building the project & starting the server
To build
go build -i -o $GOPATH/src/bitbucket.org/oscaroscar/vostok/examples/sigterm/bin/sigterm -v bitbucket.org/oscaroscar/vostok/examples/sigterm/go
To run:
cd $GOPATH/src/bitbucket.org/oscaroscar/vostok/examples/sigterm && ./bin/sigterm -config=conf/example.dev.localhost.json
One-liner for building and restarting right away (assuming the previous cd
has been run):
go build -i -o bin/sigterm -v ./go && ./bin/sigterm -config=conf/example.dev.localhost.json
Top
To test
To add new children that will do some work:
curl http://localhost:10101/sigtermexample?action=newSyncWork
To add new routines :
curl http://localhost:10101/sigtermexample?action=newAsyncWork
To add new batch works :
curl http://localhost:10101/sigtermexample?action=newBatchWork
Top