In Ghost 0.x, config was provided via a single config.js file with keys for each env.
In Ghost 1.0, config is provided via multiple config.json files
How do you provide environment variables in Ghost 1.0?
I would like to dynamically set the port value using process.env.port on Cloud9 IDE like so.
config.development.json
{
"url": "http://localhost",
"server": {
"port": process.env.port,
"host": process.env.IP
}
}
When I run the application using ghost start with the following config, it says You can access your publication at http://localhost:2368, but when I go to http://localhost:2368 in http://c9.io it gives me an error saying No application seems to be running here!
{
"url": "http://localhost:2368",
"server": {
"port": 2368,
"host": "127.0.0.1"
}
}
I managed to figure out how to do this.
Here is the solution incase if someone else is also trying to figure out how to do the same thing.
In your config.development.json file, add the following.
{
"url": "http://{workspace_name}-{username}.c9users.io:8080",
"server": {
"port": 8080,
"host": "0.0.0.0"
}
}
Alternatively, run the following command in the terminal. This will dynamically get the value for the port and host environment variable and add the above content to the config.development.json file.
ghost config url http://$C9_HOSTNAME:$PORT
ghost config server.port $PORT
ghost config server.host $IP
Related
My question is how do i get vimspector running with a ruby on rails app running passenger (I think)
I'm trying to set up vimspector with some ruby on rails projects I'm working on. Basically the problem is that vimspector doesn't stop at breakpoints in some apps. the apps are using passenger. In a very basic sample app vimspector works fine, but not in the ones where i actually need to debug.
Description:
when i call vimspector#Launch all the splits/windows come up, and a passenger application server gets launched. I don't work alone on some projects so i cannot really change this to another one.
I set some breakpoints and do actions that should stop at them but they run through like without a debugger. Also nothing except for threads running and the console output of the rails server shows up in the splits. In my processes 2 processes show up. Once the Passenger Ruby app and once a node process going to my cust_vscode-ruby directory which is needed for the debugger. The node process has the subprocess rdebug-ide and rdebug-ide has passenger start.
As vimspector works fine with the sample rails app, I don't think its a problem of the install or something like that.
I tried switching to attach but when configuring it for attach i get an endless loading without getting a timeout in the browser. the terminal window where i run rdebug-ide starts of without any repsonse, i launch vimspector and the server is being booted up. It stops at this however and never goes past booting Run rails server -h for more startup options. After which passenger normally starts up. With switching to attach mode only the rdebug controlled rails server shows up in my processes.
I think this should be possible as i'm usind ruby-debug-ide which is being used by RubyMine on which i could debug the apps running passenger just fine. I'm pretty sure that is has to do with passenger as calling it up in launch config leads to it escaping and using attach config leads to it blocking the rails server boot. But I don't know how to fix it.
.vimspector.json
same for both sample app and actual app :
{
"configurations": {
"rails": {
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server"
]
}
}
}
}
vimspector configuration output
Vimspector Debug Info
--------------------------------------------------------------------------------
ConnectionType: job
Adapter:
--------------------------------------------------------------------------------
{
"command": [
"node",
"/Users/username/.vim/plugged/vimspector/gadgets/macos/cust_vscode-ruby/dist/debugger/main.js"
],
"configuration": {
"cwd": "/Users/username/Folder/app-name",
"showDebugOutput": false,
"trace": false
},
"name": "vscode-ruby-debug",
"env": {},
"cwd": "/Users/username/Folder/app-name"
}
--------------------------------------------------------------------------------
Configuration:
--------------------------------------------------------------------------------
{
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "/Users/username/Folder/app-name",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "/Users/username/Folder/app-name/bin/rails",
"args": [
"server"
]
}
}
--------------------------------------------------------------------------------
API Prefix:
Launch/Init: True / True
Workspace Root: /Users/username/Folder/app-name
Launch Config:
--------------------------------------------------------------------------------
{
"cwd": "/Users/username/Folder/app-name",
"showDebugOutput": false,
"trace": false,
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-version/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-version/gems/ruby-debug-ide-0.7.3",
"program": "/Users/username/Folder/app-name/bin/rails",
"args": [
"server"
]
}
--------------------------------------------------------------------------------
Server Capabilities:
--------------------------------------------------------------------------------
{
"supportsConfigurationDoneRequest": true,
"supportsConditionalBreakpoints": true
}
--------------------------------------------------------------------------------
Line Breakpoints:
--------------------------------------------------------------------------------
{
"/Users/username/Folder/app-name/app/controllers/.../somethings_controller.rb": [
{
"state": "ENABLED",
"line": 83,
"options": {},
"sign_id": 1,
"server_bp": {
"verified": true,
"line": 83,
"id": 1
}
}
]
}
--------------------------------------------------------------------------------
Func Breakpoints:
--------------------------------------------------------------------------------
[]
--------------------------------------------------------------------------------
Ex Breakpoints:
None
so i got it to work not with passenger itself.
i changed my vimspector config to the following, switching up some paths to the used binaries by trial and error (i think the one that matters is calling the rails binary in the project root). The important thing is to call in the args server -u puma. Make sure to write each part of the command as a single argument. puma being the default rails server (i found it to be in my sample app), so this gets picked up by rdebug-ide and debase.
{
"configurations": {
"rails": {
"adapter": "cust_vscode-ruby",
"default": true,
"configuration": {
"name": "Debug Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"pathToBundler": "/Users/username/.rvm/rubies/ruby-RUBYVERSION/bin/bundler",
"pathToRDebugIDE": "/Users/username/.rvm/gems/ruby-RUBYVERSION/gems/ruby-debug-ide-RUBYDEBUGIDEVERSION",
"program": "${workspaceRoot}/bin/rails",
"args": [
"server", "-u", "puma"
]
}
}
}
}
There are some options I found for using passenger, it probably has to do something with writing the config as attach.
What seemed closest (but it doesn't work) to the answer seemed to copy the rubymine config that calls:
/bin/bash -c "~/.rvm/bin/rvm _RUBYVERSION_ do ~/.rvm/rubies/ruby-_RUBYVERSION_/bin/ruby ~/.rvm/gems/ruby-_VERSION_/gems/ruby-debug-ide-_RUBYDEBUG-IDEVERSION_/bin/rdebug-ide --key-value --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 42371 --host 0.0.0.0 --dispatcher-port 38403 -- ~/Folder/project/bin/rails server -b 0.0.0.0 -p 3000 -e development"
I think a point where it could be failing, and why it's not working is that passenger needs to be set to allow debugging (PassengerDebugger on), although i might just be confusing everything here. However this passenger option is reserved for the Enterprise version (https://www.phusionpassenger.com/library/admin/apache/debugging_console/ruby/).
Where this left me off was i launched this debug config but couldn't connect to the socket. Maybe this is to some security measure i made to tight for my own good on my system or more likely a fault in the config.
I think it's possible to attach to the passenger server properly somehow some ideas could maybe be found here but i didn't get anywhere with them.
https://mondotondo.com/2012/08/23/how-to-remotely-debug-rails-in-apache-passenger-rubymine/
How can I get ruby-debug-ide to work?
If you are struggeling like me with this, hang in there you will get it some day!
I'm trying to create a Swagger UI configuration to show several of my apis. They are not hosted publicly, the definition files are in my local file system. I'm using swagger ui with docker. I run it with the following command:
docker run -p 8080:8080 -v $(pwd)/_build:/spec swaggerapi/swagger-ui
In _build directory is where I have my yaml spec files. This is the swagger-config.yaml config file:
urls:
- /spec/openapi2.yaml
- /spec/openapi.yaml
plugins:
- topbar
I have also tried:
urls:
- url: /spec/openapi2.yaml
name: API1
- url: /spec/openapi.yaml
name: API2
plugins:
- topbar
After running it, this is what I see:
That's the default API of Swagger UI, so I suppose there's an error in my configuration. I have tried several things, but they have not worked and I do not seem to find any good documentation about the swagger-config.yaml configuration file.
Any idea to make it work with several APIs?
According to the comments in the Swagger UI issue tracker, the Docker version needs the config file in the JSON format rather than YAML.
Try using this swagger-config.json:
{
"urls": [
{
"url": "/spec/openapi2.yaml",
"name": "API1"
},
{
"url": "/spec/openapi.yaml",
"name": "API2"
}
],
"plugins": [
"topbar"
]
}
Also add -e CONFIG_URL=/path/to/swagger-config.json to the docker run command.
so I have established two connections aws_default and google_cloud_default in a json file like so
{
"aws_default": {
"conn_type": "s3",
"host": null,
"login": "sample_login",
"password": "sample_secret_key",
"schema": null,
"port": null,
"extra": null
},
"google_cloud_default": {
"conn_type": "google_cloud_platform",
"project_id": "sample-proj-id123",
"keyfile_path": null,
"keyfile_json": {sample_json},
"scopes": "sample_scope",
"number_of_retries": 5,
}
}
I have a local airflow server containerized in docker. What I am trying to do, is to import the connections from this file, that way I don't need to define the connections in the Airflow UI.
I have an entrypoint.sh file which runs everytime the airflow image is built.
I have included this line airflow connections import connections.json in that shell file.
in my docker-compse.yaml file, I have added a binded a volume like so
- type: bind
source: ${HOME}/connections.json
target: /usr/local/airflow/connections.json
However, when I run my DAG locally, which includes hooks that connect to these connections, I receive errors: i.e.
The conn_id `google_cloud_default` isn't defined
So I'm not too sure how to proceed. I was reading about Airflow's local filesystem secrets backend here
And it mentions this code chunk to establish the file path
[secrets]
backend = airflow.secrets.local_filesystem.LocalFilesystemBackend
backend_kwargs = {"variables_file_path": "/files/var.json", "connections_file_path": "/files/conn.json"}
But, as I check my airflow.cfg, I can't find this code chunk. Am I supposed to add this to airflow.cfg?
Could use some guidance here.. I know the solution is simple but I've naive to setting up a connection like this. Thanks!
I have an Elasticsearch deployment on Kubernetes (AKS). I'm using the official Elastic's docker images for deployments. Logs are being stored in a persistent Azure Disk. How can I migrate some of these logs to another cluster with a similar setup? Only those logs that matches a filter condition based on datetime of the logs needs to be migrated.
Please use Reindex API for achieving the same
POST _reindex
{
"source": {
"remote": {
"host": "http://oldhost:9200",
"username": "user",
"password": "pass"
},
"index": "source",
"query": {
"match": {
"test": "data"
}
}
},
"dest": {
"index": "dest"
}
}
Note:
Run the aforementioned command on your target instance.
Make sure that the source instance is whitelisted in elasticsearch.yml
reindex.remote.whitelist: oldhost:9200
Run the process asynchronously using below query param
POST _reindex?wait_for_completion=false
When I deploy a Rails app with OpsWorks, a new database.yml gets created in the shared directory. It ignores the existing database.yml (which rightfully shouldn't be in the repo), and I've also tried specifying custom JSON but nothing works. Maybe I have the structure wrong?
{
"deploy": {
"my-app-name": {
"database": {
"adapter": "mysql2",
"encoding": "unicode",
"host": "xxxxxx.rds.amazonaws.com",
"port": "3306",
"database": "db-name",
"pool": "5",
"username": "username",
"password": "password"
}
}
}
}
Look also here:
http://wojtek.ziniewi.cz/2013/06/10/custom-symlinks-in-amazon-opsworks-ror-application/
And always remember to examine your stack-json by logging into console of one of your opsworks servers and typing:
opsworks-agent-cli get_json
Using the short name for the app worked (without hyphens). I was using the full name before. See: https://forums.aws.amazon.com/message.jspa?messageID=444711