Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .ebextensions/002_overrides.config
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ files:
# this file here is just to override EBs same file
exit 0

"/opt/elasticbeanstalk/hooks/appdeploy/post/070_configure_supervisord.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash

# this file here is just to override EBs same file
exit 0

"/opt/elasticbeanstalk/hooks/appdeploy/post/080_configure_nginx.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash

# this file here is just to override EBs same file
exit 0

"/opt/elasticbeanstalk/hooks/appdeploy/enact/99_reload_app_server.sh":
mode: "000755"
owner: root
Expand Down
33 changes: 11 additions & 22 deletions .ebextensions/004_files_config_updaters.config
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,22 @@ files:
chown -R $EB_APP_USER:$EB_APP_USER $EB_APP_DEPLOY_DIR


"/opt/elasticbeanstalk/hooks/appdeploy/post/070_configure_supervisord.sh":
"/opt/elasticbeanstalk/hooks/appdeploy/post/070_configure_nginx.sh":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old files might stay during updates if machine is not get recycled

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add current file names to overrides configuration.

mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
source /etc/profile

cd $EB_APP_DEPLOY_DIR

./run exec supervisorctl stop all

echo "running with new supervisord config"
cp deployment/generated_files/supervisord.conf /etc/supervisord.conf
echo "stopping httpd if exists"
service httpd stop || echo "httpd is stopped"

service supervisord restart
echo "updated supervisord config"
echo 'koding:$apr1$K17a7D.N$vuaxDfc4kJvHAg7Id43wk1' >/etc/nginx/conf.d/.htpasswd
echo 'USER3489:$apr1$52wVqnxi$eVUrgOn8oRfPQRG8vU8jE0' >>/etc/nginx/conf.d/.htpasswd


"/opt/elasticbeanstalk/hooks/appdeploy/post/080_configure_nginx.sh":
"/opt/elasticbeanstalk/hooks/appdeploy/post/080_configure_supervisord.sh":
mode: "000755"
owner: root
group: root
Expand All @@ -151,20 +147,13 @@ files:

cd $EB_APP_DEPLOY_DIR

echo "stopping httpd if exists"
service httpd stop || echo "httpd is stopped"

echo "updating ngnix configuration"
echo "moving nginx config"
cp deployment/generated_files/nginx.conf /etc/nginx/
echo "updated nginx config"
./run exec supervisorctl stop all

echo 'koding:$apr1$K17a7D.N$vuaxDfc4kJvHAg7Id43wk1' >/etc/nginx/conf.d/.htpasswd
echo 'USER3489:$apr1$52wVqnxi$eVUrgOn8oRfPQRG8vU8jE0' >>/etc/nginx/conf.d/.htpasswd
echo "running with new supervisord config"
cp deployment/generated_files/supervisord.conf /etc/supervisord.conf

echo "restarting ngnix with current config"
service nginx restart
echo "restarted nginx"
service supervisord restart
echo "updated supervisord config"


"/opt/elasticbeanstalk/hooks/appdeploy/post/090_cleanup.sh":
Expand Down
6 changes: 6 additions & 0 deletions config/workers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module.exports = (KONFIG, options, credentials) ->
nodeProgram = if options.watchNode then './watch-node' else 'node'

workers =
nginx:
group: 'webserver'
supervisord:
command: 'nginx -c %(ENV_KONFIG_PROJECTROOT)s/nginx.conf'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nginx.conf/deployment/generated_files/nginx.conf

also could you remove the fs.writeFileSync "./nginx.conf", KONFIG.nginxConf line from configure? any idea why we are duplicating it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also change the "stopsignal" to QUIT for supervisord conf of this worker? we will make sure that nginx is restarted/stopped gracefully.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall. I suppose it was just to have a shorter path.

Stop signal is a good catch. Also, that reminded me an old observation. I think supervisorctl shutdown kills the subprocesses because it is much faster than supervisorctl stop all. I'll dig into it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove redundant configuration output files in a separate pull request.

stopsignal: 'QUIT'

bucketproxies :
group : 'bucket'
nginx :
Expand Down
1 change: 1 addition & 0 deletions deployment/nginx.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ module.exports.create = (KONFIG, environment) ->
worker_processes #{if inDevEnvironment then 1 else 16};
master_process #{if inDevEnvironment then 'off' else 'on'};

daemon off;

#error_log logs/error.log;
#error_log logs/error.log notice;
Expand Down
2 changes: 1 addition & 1 deletion deployment/supervisord.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ generateWorkerSection = (app, options = {}) ->
autorestart : yes
startsecs : 10
startretries : 5
stopsignal : 'TERM'
stopsignal : options.stopsignal or 'TERM'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed, line 65 already handles those

stopwaitsecs : 10
stopasgroup : yes
killasgroup : yes
Expand Down
1 change: 0 additions & 1 deletion scripts/bootstrap-container
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function run_backend() {
go/build.sh
./run is_ready || exit 255
./run migrations up
nginx -c $(pwd)/nginx.conf
./run exec supervisord -c supervisord.conf
sleep 2
tail --follow --lines +0 --quiet .logs/*.log
Expand Down