Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Baur
cloudify3
Commits
ba66a3c9
Commit
ba66a3c9
authored
Jun 16, 2015
by
Daniel Baur
Browse files
Replaced ghost start script with python script
parent
583d812a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
244 additions
and
18 deletions
+244
-18
ghost-openstack/resources/ghost/ghost.default.template
ghost-openstack/resources/ghost/ghost.default.template
+137
-0
ghost-openstack/scripts/ghost/ghost.py
ghost-openstack/scripts/ghost/ghost.py
+89
-0
ghost-openstack/scripts/ghost/start-ubuntu.sh
ghost-openstack/scripts/ghost/start-ubuntu.sh
+0
-15
ghost-openstack/types/ghost.yaml
ghost-openstack/types/ghost.yaml
+18
-3
No files found.
ghost-openstack/resources/ghost/ghost.default.template
0 → 100644
View file @
ba66a3c9
// # 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
ghost-openstack/scripts/ghost/ghost.py
0 → 100644
View file @
ba66a3c9
###############################################################################
# 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
ghost-openstack/scripts/ghost/start-ubuntu.sh
deleted
100755 → 0
View file @
583d812a
#!/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"
ghost-openstack/types/ghost.yaml
View file @
ba66a3c9
...
...
@@ -46,9 +46,24 @@ node_types:
derived_from
:
cloudify.nodes.ApplicationModule
interfaces
:
cloudify.interfaces.lifecycle
:
# configure: scripts/nodecellar/install-nodecellar-app.sh
start
:
scripts/ghost/start-ubuntu.sh
# stop: scripts/nodecellar/stop-nodecellar-app.sh
configure
:
implementation
:
scripts/ghost/ghost.py
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
################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment