Commit ba66a3c9 authored by Daniel Baur's avatar Daniel Baur

Replaced ghost start script with python script

parent 583d812a
// # Ghost Configuration
// Setup your Ghost install for various environments
// Documentation can be found at http://support.ghost.org/config/
var path = require('path'),
config;
config = {
// ### Production
// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: 'http://my-ghost-blog.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
// Host to be passed to node's `net.Server#listen()`
host: '0.0.0.0',
// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '2368'
}
},
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and email.
// Change this to your Ghost blogs published URL.
url: 'http://localhost:2368',
// Example mail config
// Visit http://support.ghost.org/mail for instructions
// ```
// mail: {
// transport: 'SMTP',
// options: {
// service: 'Mailgun',
// auth: {
// user: '', // mailgun username
// pass: '' // mailgun password
// }
// }
// },
// ```
database: {
client: 'pg',
connection: {
host : '{{ postgre_ip }}',
user : 'postgres',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
// Host to be passed to node's `net.Server#listen()`
host: '0.0.0.0',
// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '2368'
},
paths: {
contentPath: path.join(__dirname, '/content/')
}
},
// **Developers only need to edit below here**
// ### Testing
// Used when developing Ghost to run tests and check the health of Ghost
// Uses a different port number
testing: {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-test.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing MySQL
// Used by Travis - Automated testing run through GitHub
'testing-mysql': {
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'root',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing pg
// Used by Travis - Automated testing run through GitHub
'testing-pg': {
url: 'http://127.0.0.1:2369',
database: {
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
}
};
// Export config
module.exports = config;
\ No newline at end of file
###############################################################################
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
import os
import subprocess
import tempfile
from contextlib import contextmanager
from jinja2 import Template
from cloudify_rest_client import exceptions as rest_exceptions
from cloudify import ctx
from cloudify.state import ctx_parameters as inputs
from cloudify import exceptions
from cloudify import utils
CONFIG_PATH = '~/ghost/config.js'
TEMPLATE_RESOURCE_NAME = 'resources/ghost/ghost.default.template'
def configure(subject=None):
subject = subject or ctx
ctx.logger.info('Configuring ghost.')
_run('sudo apt-get install unzip','Failed installing unzip')
_run('curl -L https://ghost.org/zip/ghost-latest.zip -o ~/ghost.zip','Failed downloading ghost')
_run('unzip -uo ~/ghost.zip -d ~/ghost','Failed unzipping ghost')
template = Template(ctx.get_resource(TEMPLATE_RESOURCE_NAME))
ctx.logger.debug('Building a dict object that will contain variables '
'to write to the Jinja2 template.')
config = subject.node.properties.copy()
config.update(dict(
postgre_ip=subject.instance.runtime_properties.postgre_ip_address))
ctx.logger.debug('Rendering the Jinja2 template to {0}.'.format(CONFIG_PATH))
ctx.logger.debug('The config dict: {0}.'.format(config))
with tempfile.NamedTemporaryFile(delete=False) as temp_config:
temp_config.write(template.render(config))
#_run('sudo /usr/sbin/haproxy -f {0} -c'.format(temp_config.name),
# error_message='Failed to Configure')
_run('sudo mv {0} {1}'.format(temp_config.name, CONFIG_PATH),
error_message='Failed to write to {0}.'.format(CONFIG_PATH))
def start():
_run('npm install','Failed running npm install')
_run('npm start','Failed running npm start')
def stop():
_run('sudo killall nodejs','Failed killing nodejs')
def _run(command, error_message):
runner = utils.LocalCommandRunner(logger=ctx.logger)
try:
runner.run(command)
except exceptions.CommandExecutionException as e:
raise NonRecoverableError('{0}: {1}'.format(error_message, e))
def _main():
invocation = inputs['invocation']
function = invocation['function']
args = invocation.get('args', [])
kwargs = invocation.get('kwargs', {})
globals()[function](*args, **kwargs)
if __name__ == '__main__':
_main()
\ No newline at end of file
#!/bin/bash -e
ctx logger info "Starting ghost"
ctx logger debug "${COMMAND}"
sudo apt-get install unzip
cd ~
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
unzip -uo ghost.zip -d ghost
cd ghost
npm install --production
npm start
ctx logger info "Starting ghost"
...@@ -46,9 +46,24 @@ node_types: ...@@ -46,9 +46,24 @@ node_types:
derived_from: cloudify.nodes.ApplicationModule derived_from: cloudify.nodes.ApplicationModule
interfaces: interfaces:
cloudify.interfaces.lifecycle: cloudify.interfaces.lifecycle:
# configure: scripts/nodecellar/install-nodecellar-app.sh configure:
start: scripts/ghost/start-ubuntu.sh implementation: scripts/ghost/ghost.py
# stop: scripts/nodecellar/stop-nodecellar-app.sh inputs:
invocation:
default:
function: configure
start:
implementation: scripts/ghost/ghost.py
inputs:
invocation:
default:
function: start
stop:
implementation: scripts/ghost/ghost.py
inputs:
invocation:
default:
function: stop
################################################################ ################################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment