A web application development model based on the idea of scaling through processes is becoming increasingly popular. A modern application is a set of running processes that do not store states, each isolated from each other. Each such process is assigned its own local port, which allows you to transparently export your services for later use by someone else, maybe even with each other (for example, one serves http requests from users, accepting video url addresses, and the other slowly, but surely loads them and converts them). As a rule, in most cases http-services are simply installed as reverse proxy in nginx, but options are possible.web: mono ./awesome-app --port $PORT api: node ./api.js -p $PORT worker: bundle exec rake resque:work QUEUE=* habr: bundle exec ./bin/thin -a localhost -p $PORT  $ gem install foreman  $ editor .env $ foreman start 
$PORT variable is automatically set by Foreman separately for each process launched. $ foreman export upstart /etc/init [foreman export] writing: /etc/init/testapp.conf [foreman export] writing: /etc/init/testapp-web.conf [foreman export] writing: /etc/init/testapp-web-1.conf [foreman export] writing: /etc/init/testapp-worker.conf [foreman export] writing: /etc/init/testapp-worker-1.conf [foreman export] writing: /etc/init/testapp-habr.conf [foreman export] writing: /etc/init/testapp-habr-1.conf  $ start testapp $ stop testapp-habr $ restart testapp-worker-1  $ foreman export inittab # ----- foreman testapp processes ----- TE01:4:respawn:/bin/su - testapp -c 'PORT=5000 mono ./awesome-app --port $PORT >> /var/log/testapp/web-1.log 2>&1' TE02:4:respawn:/bin/su - testapp -c 'PORT=5100 bundle exec rake resque:work QUEUE=* >> /var/log/testapp/worker-1.log 2>&1' TE03:4:respawn:/bin/su - testapp -c 'PORT=5200 bundle exec ./bin/thin -a localhost -p $PORT >> /var/log/testapp/habr-1.log 2>&1' # ----- end foreman testapp processes ----- 
 #      «worker»,   «habr»   «web» $ foreman start -c habr=4 -c web=2  #   ,   ,    upstart $ foreman export upstart /etc/init -c habr=4 -c web=2  #    «worker» $ foreman start -c worker=0 .env file containing an enumeration of all the necessary values of environment variables, for example: APP_ENV=production DATABASE_URL=mysql://user:password@localhost/table sample.env file, which will contain an example of your application configuration. Thus, to deploy it in a new environment, you will need to copy the sample.env file to .env , edit it in accordance with your environment, and then launch Foreman. $ foreman start -e development.env  $ foreman start -p 7000 Source: https://habr.com/ru/post/176947/
All Articles