Capistrano 3 - How to have deploy_to location in different stages - capistrano3

How do I set different deploy_to locations in my different stages.
If I put
:set :deploy_to, '/var/www/mywebsite'
in deploy.rb my app deploys successfully, but I want to have different deploy_to locations in production.rb and staging.rb, however if I move this line to the different files the app will not deploy, it uses the default deploy_to location of /var/www/my_app

Related

Restrict a file to being edited in gitlab (.gitlab-ci.yml)

as you know We have a file for gitlab ci configuration named '.gitlab-ci.yml'
and this file shouldn't be edited by any developers so I decided to avoid developers to edit it.
the thing is gitlab said you can lock file to being edited but the prerequirement of this action is to have a premium account.
what can I do when I haven't premium account?
do you have any idea to lock a file to being edited?
Check if you have access to a Push Rule feature, which is a kind of pre-receive hook.
Or you can set a pre-receive hook if your GitLab server is on-premise.
In both cases, you can list the files being pushed in that hook, and fails if one of them is .gitlab-ci.yml.
As of today, the official way (~workaround~) for this seems to be creating a different repository for the .yml file with more restrict permissions and then referencing that .yml file from your project:
A .gitlab-ci.yml may contain rules to deploy an application to the production server. This deployment usually runs automatically after pushing a merge request. To prevent developers from changing the .gitlab-ci.yml, you can define it in a different repository. The configuration can reference a file in another project with a completely different set of permissions (similar to separating a project for deployments). In this scenario, the .gitlab-ci.yml is publicly accessible, but can only be edited by users with appropriate permissions in the other project.
https://docs.gitlab.com/ee/ci/environments/deployment_safety.html#protect-gitlab-ciyml-from-change
Also, there is a discussion on this matter here:
https://gitlab.com/gitlab-org/gitlab/-/issues/15632

Getting the real appdata folder under Desktop Bridge

I've got a WPF app that writes data to %appdata%. I understand the writes get redirected to a per-app location, but I want to have a menu option in my app to open the folder with the app data. As far as the app is concerned, it's writing to C:\Users\myusername\AppData\Roaming\VidCoder-Beta\ but it's actually writing somewhere else. However when I try to open an explorer window it goes to the first location (where the data isn't). How can I get the actual write location from inside the app?
UWP apps store their appdata in a subfolder located in
C:\Users\username\AppData\Local\Packages
This should be where your app is now storing its data, under a subfolder that is most likely named with a random set of characters. To find out which random folder your app is, look in the Packaging section of the application manifest. (Package.AppXManifest). The "Package Family Name" should be part of the name of your app's appdata folder, as in this image. Once you've found the folder, local data is stored under the subfolder LocalState, roaming data under the folder RoamingState.

How do I store the private key of my server in google app engine?

I'm using "github.com/dgrijalva/jwt-go" to create JSON web tokens.
When I hosted my server locally, I could use my private key as usual. But in GAE it won't work because I don't have access to the file system.
How would you guys do it? Store the key in datastore or any other ideas?
Thanks
Edit:
My app.yaml looks like this (below api_version and stuff):
handlers:
- url: /.*
script: _go_app
On AppEngine you don't have access to the file system of the host operating system, but you can access files of your web application (you have read-only permission, you can't change them and you can't create new files in the app's folder).
So the question is: do you want to change this private key from your application without redeploying your app? Or it is perfectly fine if it is deployed "statically" with your app's code?
If you don't need to change it (or only when you redeploy your app), easiest is to store it as a "static" file as part of your webapp. You may refer to files of your app using relative paths, where the current or working directory is your app's root. E.g. if your app contains a key folder in its root (where app.yaml resides), and there is a my_key.txt file inside the key folder, you can refer to it with the path: key/my_key.txt.
Actually it is quite common to "ship" static files with your app's code: just think of HTML templates which are read and processed by the Go code (e.g. package html/template) to produce HTML result; the content of the HTML template files are not served directly to clients.
If you need to change it from time to time without having to redeploy your app, then store it in the Datastore which your app can read and modify.
Note:
One important note: not every file is readable by code, this depends on the app configuration. Quoting from Configuring with app.yaml / Static file handlers:
Static files are files to be served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them.
For efficiency, App Engine stores and serves static files separately from application files. Static files are not available in the application's file system. If you have data files that need to be read by the application code, the data files must be application files, and must not be matched by a static file pattern.
Static file handlers can be defined in two ways: as a directory structure of static files that maps to a URL path, or as a pattern that maps URLs to specific files.
Read the link how to properly configure application and static files / directories.
The solution was to leave app.yaml as it were. Put app.yaml at root lvl in project. Then change all imports from starting at GOPATH to start at project root instead. The problem that made me choose to put app.yaml and main go file in a different folder under project root was because of double imports. Read this for a better understanding: Google Go AppEngine imports and conflicts when serving / testing
The solution made my project find the files I wanted.

What files make one Wordpress site different from another

Migrating wordpress sites between hosts can take a lot of time, especially when the hosting platforms are different.
I have been trying to migrate my sites from Cpanel to Mediatemple, but it seems like im just not getting it right.
There is various options
Use the guide they provide
https://kb.mediatemple.net/questions/1556/Migrating+your+websites+to+the+Grid#gs
When moving the files in this way the permissions of the files are not set properly and I would have to got back through them and figure out which ones need to change.
The database export from PHPMyAdmin also does not look the same it looks in the screenshot
Using InfiniteWP
To use InfiniteWP you must provide the url of the site and since I dont want to change the DNS until the site is moved this option does not seems to be ideal.
This option might work if its ok for the sites to be unavailable for a day or so while the DNS resolves...
But I don't want the sites to be unavailable
Using Mediatemples "one click apps" to install wordpress and then moving only the files that are unique to the site from the old host to the new host.
I would like to use this option
I think that the content of the WP-Content folder needs to be moved that the database needs to be moved.
My question is
- what folders and files in a standard wordpress install typically hardly ever changes from one site to the other.
- can I use the wordpress database export and import function to move the database from one site to the other.
Any help will be appreciated
Thank you
With InfiniteWP, you can use the clone an existing site command (which can be found in "Tool"->"Install / Clone WP") to migrate a site to a new server.
You have to use a temporary (sub)domain pointing to the new server.
To answer your questions :
/wp-content/ stores all your files and sometimes plugin files, wp-config.php is where your configuration is stored (e.g. credentials to access the database). Depending on your servers, the .htaccess files may be different.
I would recommend to create a dump file of your entire database using phpMyAdmin.

cakephp 2 apps same file name issue

I have 2 apps sharing the same cake core. Both apps contains similar file names for controllers and models. If debug is ON (> 0), both applications are working without any error. If it is off, whichever app I taken first in the url will work and other will show error like the method not found in the logs. I know, this is something related to cache.
Both apps have different tmp folder and I have given necessary permission. But the second app is taking looking into the tmp of first one so that app2 methods will not be there in that tmp. I checked by deleting the cache files and sometimes they are not regenerating. How to solve this issue ?
My folder structure
project folder
app1
Controller
Model
tmp
etc
app2
Controller
Model
tmp
etc
lib
cake
It is a cache issue. You most likely are using APC and did not specify unique prefix for cache config for each app. Be sure to change the default $prefix = "myapp_"' line in app/Config/core.php to unique values for each app.

Resources