#NEWLINE# def deploy( settings ) : #NEWLINE# #INDENT# def install( ) : #NEWLINE# #INDENT# meteor_path = '/var/www/.meteor' #NEWLINE# with quiet ( ) : #NEWLINE# #INDENT# install_meteor = False #NEWLINE# if sudo ( ( 'test -d %s' % meteor_path ) , user = 'www-data' ) . failed : #NEWLINE# #INDENT# install_meteor = True #NEWLINE# #UNINDENT# #UNINDENT# if install_meteor : #NEWLINE# #INDENT# sudo ( 'chown www-data:www-data /var/www/' ) #NEWLINE# with shell_env ( HOME = '/var/www' ) : #NEWLINE# #INDENT# sudo ( 'curl https://install.meteor.com | sed "s/if sudo cp/if echo/g"| /bin/sh 2>&1 | grep -v "%"' , user = 'www-data' ) #NEWLINE# #UNINDENT# sudo ( ( 'ln -f -s %s/tools/latest/bin/meteor /usr/local/bin/meteor' % meteor_path ) ) #NEWLINE# #UNINDENT# #UNINDENT# def meteor_upstart( ) : #NEWLINE# #INDENT# auto_start = ( '\n        description "meteor"\n        start on runlevel [2345]\n        stop on runlevel [06]\n        respawn\n\n        script\n            cd "%s"\n            exec sudo -u www-data meteor\n        end script\n        ' % remote_path ) #NEWLINE# file = StringIO ( textwrap . dedent ( auto_start ) ) #NEWLINE# put ( file , ( '/etc/init/depl_%s.conf' % settings [ 'id' ] ) , use_sudo = True ) #NEWLINE# sudo ( 'service depl_meteor restart' ) #NEWLINE# #UNINDENT# locations = { #NEWLINE# #INDENT# '/' : '\n        proxy_pass http://localhost:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection "upgrade";\n        proxy_set_header Host $host;\n    ' , #NEWLINE# #UNINDENT# } #NEWLINE# nginx_conf = _utils . nginx_config ( settings , locations ) #NEWLINE# remote_path = ( '/var/www/depl_' + settings [ 'id' ] ) #NEWLINE# mongo_commands = mongodb . deploy ( settings ) #NEWLINE# commands = ( _utils . move_project_to_www ( settings [ 'path' ] , remote_path ) , install , meteor_upstart , _utils . generate_ssl_keys ( settings [ 'id' ] , settings [ 'ssl' ] ) , _utils . install_nginx ( mongo_commands , settings [ 'id' ] ) ) #NEWLINE# return ( ( ( Package ( 'nodejs' ) , ) + mongo_commands ) + commands )